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

高手帮忙看一下!!!!谢谢了!!!!!!

Posted by y05wlm at 2006-04-09 17:45:38 on Problem 1047
#include<iostream>
int main()
{
	using namespace std;
	char c[61],a[61];
	int  clen;
	int  mtply;
	int  n;
	int possi;
	int  i,j;
	while(cin>>c)
	{
		possi=1;
		strcpy(a,c);
		clen=strlen(c);
	//	if(clen<9) m=clen;
	//	else m=10;
		for(mtply=2;mtply<=clen;mtply++)
		{
			
			int temp1=0,temp2=0;
			for(i=clen-1;i>=0;i--)
			{
				temp1=((c[i]-'0')*mtply+temp2)/10;
				c[i]=((c[i]-'0')*mtply+temp2)%10;
				temp2=temp1;
			}
			for(j=clen-1;j>0;j--)
			{
				
				if(c[j]>10)
				{
				c[j-1]+=c[j]/10;
				c[j]=c[j]%10;
				}
				
			}
			if(c[0]>=10){ possi=0; break;}
			//第几个数开始相等
			for(i=0;i<clen;i++)
			{   
				if(a[0]==c[i]+'0') n=i;
				
			}//比较是否circle
			for(i=0,j=n;i<clen&&j<clen;i++,j++)
			{
				if(a[i]!=c[j]+'0') possi=0;
			}
			for(i=0,j=clen-n;i<clen&&j<clen;i++,j++)
			{
				if((c[i]+'0')!=a[j]) possi=0;
			}
			if(possi==1) break;
		}
		if(possi==1) cout<<a<<" is cyclic"<<endl;
		else cout<<a<<" is not cyclic"<<endl;
	}
	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