Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

why wrong answer? UA80 GUYS

Posted by AC22 at 2008-07-20 09:23:03 on Problem 1047
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator