Run ID:3594
提交时间:2024-06-15 17:09:49
# include<iostream> # include<cstring> using namespace std; int is_pd(string s1){ int n = s1.size(); for(int i = 0; i < n/2+n%2; i++)if(s1[i]!=s1[n-1-i])return 0; return n; } int main(){ string a; int _max = 1; cin>>a; int s = a.size(); for(int i = 0; i < s-1; i++){ for(int j = i+1; j < s; j++){ int c = is_pd(a.substr(i, j-i+1)); if(c>_max)_max = c; } } cout<<_max; return 0; }