1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 char s[65],b[65],str[60][65]; 6 int i,k,t,c,len; 7 bool flag; 8 while(~scanf("%s",s)){ 9 len=strlen(s); 10 for(i=0;i<len;++i){ 11 strcpy(str[i],s+i); 12 strncat(str[i],s,i); 13 } 14 for(k=2;k<=len;++k){ 15 memset(b,0,sizeof(b)); 16 for(b[len]=c=0,i=len-1;i>=0;--i){ 17 t=(s[i]-'0')*k+c; 18 b[i]=t%10+'0'; 19 c=t/10; 20 } 21 if(c) break; 22 for(flag=i=0;i<len;++i) 23 if(!strcmp(b,str[i])){ 24 flag=1; 25 break; 26 } 27 if(!flag) break; 28 } 29 if(k>len) printf("%s is cyclic\n",s); 30 else printf("%s is not cyclic\n",s); 31 } 32 return 0; 33 }
//第一次提交第8行的‘~’竟然忘了写了!!结果杯具了半天!!细心啊!!