| ||||||||||
| 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 | |||||||||
why wrong answer? UA80 GUYS#include"stdio.h"
#include"string.h"
int main()
{ __int64 a,b;
int i,j,k,m,count,len,x;
char str[65],aa[65];
while(scanf("%s",aa)!=EOF)
{ len=strlen(aa); b=0;
for(k=0;k<len;k++)
b=b*10+aa[k]-'0';
for(i=0;i<len;i++)
{ j=0; a=b; a=a*(i+1);
if(a==0) { printf("%s is cyclic\n",aa); break; }
while(a)
{ str[j]=int(a%10)+'0';
a=a/10; j++; str[j]='\0'; x=strlen(str);
}
for(j=x;j<len;j++)
str[j]='0';
str[j]='\0';
for(j=0;j<len;j++)
{ if(aa[j]==str[0])
{ k=0; m=j; count=0;
while(aa[m]==str[k])
{ count++; k++; m--;
if(k>len-1) k=0;
if(m<0) m=len-1;
if(count==len) break;
} if(count==len) break;
}
}
if(j==len) { printf("%s is not cyclic\n",aa); break; }
} if(i==len) { printf("%s is cyclic\n",aa); }
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator