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:没有使用KMP算法,但是就查不出哪里有错误! 一直WA!#include<stdio.h> #include<string.h> void main() { int len,l,b,i,t; char s[1000000]; scanf("%s",s); while(strcmp(s,".")!=0) { len=strlen(s); for(l=1;l<=len;l++) { if(len%l!=0) continue; for(b=0;b+l<len;b+=l) { i=0;t=1; while(i<l) { if(s[b+i]!=s[b+l+i]) t=0; i++; } if(t!=1) break; } if(b+l>=len) break; } //printf("%d\n",l); printf("%d\n",len/l); scanf("%s",s); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator