原题链接:http://ac.jobdu.com/problem.php?pid=1528
小白书上的做法,不过这个还要简单些。。。
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
using std::max;
const int Max_N = ;
char ret[Max_N];
void solve() {
int i, j, ans = , n = strlen(ret);
for (i = ; i < n; i++) {
for (j = ; i >= j && i + j < n; j++) {
if (ret[i - j] != ret[i + j]) break;
ans = max(ans, j << | );
}
for (j = ; i >= j && i + j + < n; j++) {
if (ret[i - j] != ret[i + j + ]) break;
ans = max(ans, (j << ) + );
}
}
printf("%d\n", ans);
}
int main() {
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w+", stdout);
#endif
while (gets(ret)) solve();
return ;
}