Run ID:3564
提交时间:2024-06-15 14:34:30
#include<iostream> using namespace std; bool ispd(string s,int lens){ int temp=lens/2; for(int f=0,l=lens-1;f<temp;f++,l--) if(s[f]!=s[l]) return 0; return 1; } int main(){ string s; cin>>s; int lens=s.size(),longest=0; for(int i=0;i<lens;i++) for(int j=1;j<=lens-i;j++) if(ispd(s.substr(i,j),j)) if(j>longest) longest=j; cout<<longest; return 0; }