A palindrome is a word that can be read the same way in either direction. More formally if a string is d (d > 0) characters length and the i-th character is ai , the string is palindrome if and only if ai equals a(d−i+1) for 1 ≤ i ≤ d. For example “abcba” is palindrome while “aaab” is not.
    It is known that everyone who gets to know palindromes, begin an emotional relationship with these beautiful strings. The harmony between the letters makes them artistic. But the 89’s (those who entered AUT at 1389) claim they love another kind of strings. It is called alindrome. Actually an alindrome is the result of concatenation of two palindromes. For example “abacc”=“aba”+“cc” is alindrome.
    Now you should write a program to distinguish alindromes, palindromes and other kind of strings.
Input
The first line contains T (T ≤ 50), the number of tests. Each test that comes in a separate line contains a string to be checked. Input strings contain only lower case letters (‘a’ to ‘z’) and their length will be at most 200000.
Output
For each test output a single word in a single line. If the input string can be made by concatenating two palindromes, output ‘alindrome’. Otherwise if it’s a palindrome output ‘palindrome’. In any other case print ‘simple’. (Quotes for clarity)
Sample Input
4
aaa
aabaa
aabaaa
abc
Sample Output
alindrome
palindrome
alindrome
simple

问题链接:UVA11888 Abnormal 89’s
问题简述:(略)
问题分析:回文判定问题,这里用暴力来解决。也许用Manachar算法是正解。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* UVA11888 Abnormal 89's */#include <bits/stdc++.h>using namespace std;const int N = 200000;
char s[N + 1];bool isPalindrome(char s[], int l, int r)
{while (l < r) {if (s[l] != s[r]) return false;l++, r--;}return true;
}int main()
{int t;scanf("%d", &t);while (t--) {scanf("%s", s);int len = strlen(s);int ans = 0;for (int i = 0; i < len - 1; i++)if (s[0] == s[i] && s[i + 1] == s[len - 1])if (isPalindrome(s, 0, i) && isPalindrome(s, i + 1, len - 1)) {ans = 1;break;}if (ans == 0) {if (isPalindrome(s, 0, len - 1)) ans = 2;else ans = 3;}if (ans == 1) puts("alindrome");else if (ans == 2) puts("palindrome");else puts("simple");}return 0;
}

UVA11888 Abnormal 89‘s【回文】相关推荐

  1. hdu 3613 扩展kmp+回文串

    题目大意: 给个字符串S,要把S分成两段T1,T2,每个字母都有一个对应的价值,如果T1,T2是回文串(从左往右或者从右往左读,都一样),那么他们就会有一个价值,这个价值是这个串的所有字母价值之和,如 ...

  2. hpuoj--1093: 回文数(一)

    1093: 回文数(一) 时间限制: 1 Sec  内存限制: 128 MB 提交: 3  解决: 3 [提交][状态][讨论版] 题目描述 若一个数(首位不为0)从左到右读与从右到左读都是一样,这个 ...

  3. UVa 11027 - Palindromic Permutation 回文串,组合加搜索

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=115&page=s ...

  4. 判断一个字符串是否为回文-链队(新建,进队,出队),链栈(新建,进栈,出栈)...

    回文:字符对称排列的字符串,例如ABCBA 思路:根据队:先进先出和栈: 先进后出的原则,进行比较出队和出栈的字符是否相等.如果相等,则为回文. 创建控制台应用程序. 1 #region 字符节点类 ...

  5. Ural 1297 Palindrome(后缀数组+最长回文子串)

    https://vjudge.net/problem/URAL-1297 题意: 求最长回文子串. 思路: 先将整个字符串反过来写在原字符串后面,中间需要用特殊字符隔开,那么只需要某两个后缀的最长公共 ...

  6. 【作业】随机数+参数可变的方法+实验任务(输出素数+使用递归,判断是否为回文+统计一篇英语问斩单词出现频率)...

    (1)随机数 取余的m很大可以保证随机的更彻底,更不容易重复 1 import java.util.Scanner; 2 public class Text_001 3 { 4 5 public st ...

  7. HDOJ---1431 素数回文[素数筛选+ltoa函数(将长整形转换成字符数组)+打表]

    素数回文 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submi ...

  8. 北理乐学回文数的思考(附代码)

    提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 题目 若一个数(首位不为零)从左向右读与从右向左读都一样,我们就将其称之为回文数. 例如:给定一个10进制数56,将56加65(即把5 ...

  9. 10000内的回文数c语言,回文数

    "回文"是指正读反读都能读通的句子,它是古今中外都有的一种修辞方式和文字游戏,如"我为人人,人人为我"等.在数学中也有这样一类数字有这样的特征,成为回文数(pa ...

最新文章

  1. 2020 AI产业图谱启动,勾勒中国AI技术与行业生态
  2. mysql 开启远程访问
  3. 抖音之后,互联网失去创造力
  4. web前端技术分享:web前端的求职前景好不好?
  5. 苹果市值突破2万亿美元;华为推出PC版HMS“擎云生态”;Android11将强制应用使用内置相机 | 极客头条
  6. 炫酷背光文字html,PS制作背光放射出来的文字效果
  7. 【文献调研】SLAM方向综述性论文
  8. (2)pokeman_简单卷积分类的例子
  9. Directx11教程四十六之FBX SDK
  10. AlphaStar 实战技巧分析
  11. 互联网常见通用的运营数据指标
  12. 禁忌搜索算法求解TSP旅行商问题Matlab实现
  13. Socket协议编程实践
  14. 火雷噬嗑 (易經大意 韓長庚)
  15. 程序员最恐怖的噩梦是什么?
  16. 这是你的船--读后感
  17. Python量化学习笔记02——量化投资——以Python为工具 Part01-C02
  18. SheetJS---(js-xlsx)
  19. sqli-labs第七关
  20. 经常去KTV的朋友们注意了!

热门文章

  1. openssl pkeyutl执行SM2椭圆曲线数字签名
  2. java类型转换 float类型转换_Java类型转换 – float(和long)到int
  3. ArcGIS Maritime Server 开发教程(六)Maritime Service 开发技巧
  4. erlang四大behaviour简述
  5. Comet:基于HTTP长连接的“服务器推”技术
  6. 如何制作一个横版格斗过关游戏 Cocos2d-x 2.0.4
  7. Android常用Adapter用例
  8. PhoneGap跨平台移动应用开发框架体验
  9. 基于nginx搭建直播,web播放视频方案
  10. anaconda3环境整体打包放在Spark集群上运行