Given a string, you are supposed to output the length of the longest symmetric sub-string. For example, given "Is PAT&TAP symmetric?", the longest symmetric sub-string is "s PAT&TAP s", hence you must output 11.
Input Specification:
Each input file contains one test case which gives a non-empty string of length no more than 1000.
Output Specification:
For each test case, simply print the maximum length in a line.
Sample Input:
Is PAT&TAP symmetric?
Sample Output:
11 解题思路:枚举,但需要把输入的字符串进行填充,abba不能通过枚举来判断为回文串,但可以通过填充,例如-1a-1b-1b-1a-1,此时就不会出现abba不是回文串了。
#include#include #include #include using namespace std;int main(){ vector str; char s[1002]; gets(s); int length=strlen(s); int i,j; for(i=0;i =0&&r length?max:length; } printf("%d\n",max/2); return 0;}