Run ID:123620
提交时间:2025-07-06 19:37:01
#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; int main(){ string str; int maxLen=1; cin>>str; for(int i=0;i<str.size();i++){ int temp=0; for(int j=str.size()-1;j>i;j--){ if(i+temp<j&&str[i+temp]==str[j]){ temp++; } else{ temp=0; continue; } if((i+temp)==(j-1)&&(2*temp+1)>maxLen) maxLen=(2*temp+1); else if((i+temp)==j&&(2*temp)>maxLen) maxLen=(2*temp); } } cout<<maxLen<<endl; return 0; }