Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
123617 | 刘珩宇 | 最长回文子串 | C++ | Accepted | 4 MS | 280 KB | 671 | 2025-07-06 19:31:08 |
#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(){ int i,l,j,m=1,t; string s; getline(cin,s); l=s.size(); for(i=0;i<l;i++){ t=0; for(j=l-1;j>i;j--){ if((i+t<j)&&(s[i+t]==s[j])){ t++; } else{ t=0; continue; } if((i+t)==(j-1)&&(2*t+1)>m){ m=2*t+1; } else if((i+t)==j&&(2*t)>m){ m=2*t; } } } cout<<m; return 0; }