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 |
大家来看看我的为什么wa#define MAX_LENGTH 1000001 #include<stdio.h> char s[MAX_LENGTH]; int next[MAX_LENGTH]; int length,count,num=0; void get_next(char s[],int next[]) { int i=1,j=0; next[1]=0; while(i<=length) { if(j==0||s[i]==s[j]) { i++; j++; next[i]=j; } else j=next[j]; } } void func() { printf("Test case #%d\n",++num); for(int k=2;k<=length;k++) { if(k%((k+1)-next[k+1])==0) { count=k/((k+1)-next[k+1]); if(count!=1) printf("%d %d\n",k,count); } } printf("\n"); } int main() { //freopen("in.txt","r",stdin); while(1) { scanf("%d",&length); if(!length) break; scanf("%s",s+1); get_next(s,next); func(); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator