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,郁闷~~ #include<stdio.h> #include<stdlib.h> #include<string.h> int power(char *s,int len) { register int divide,test,flag=1; char tmp1[500000],tmp2[500000]; for(divide=1;divide<len;divide++) { if(len%divide==0) { strncpy(tmp1,s,divide); tmp1[divide]='\0'; for(test=divide;test<len;test+=divide) { strncpy(tmp2,s+test,divide); tmp2[divide]='\0'; if(strcmp(tmp1,tmp2)!=0) { flag=0; break; } } if(flag) return len/divide; else flag=1; } } return 1; } int main(void) { char str[1000001]; while(scanf("%s",str)) { if(strcmp(str,".")==0) break; printf("%d\n",power(str,strlen(str))); } system("PAUSE"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator