Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
暴力超时了 杯具#include<stdio.h> #include<string.h> #define MAXN 1000000 + 10 char s[MAXN]; int main() { int cas=1,i,j,max,l; while(1) { gets(s); if(s[0]=='E') break; max=0; l=strlen(s); for(i=0; i<l; i++) { for(j=0; i-j>=0 && i+j<l; j++) { if(s[i-j]!=s[i+j]) break; if(2*j+1>max) max=2*j+1; } for(j=0; i-j>=0 && i+j+1<l; j++) { if(s[i-j]!=s[i+j+1]) break; if(2*j+2>max) max=2*j+2; } } printf("case %d: %d\n",cas++,max); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator