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

在本地所有官方数据都过了,却还是RE,谁帮我看看....谢谢

Posted by yellowflying at 2006-08-03 01:37:37 on Problem 1047
#include <stdio.h>
#include <string.h>
typedef struct num num;
struct num
{
	int d[200];
	int len;
};
void addhigh(num &a,num b)
{
	int i,jin=0;
	for(i=0;i<a.len||i<b.len||jin>0;i++)
	{
		a.d[i]=a.d[i]+b.d[i]+jin;
		jin=a.d[i]/10;
		a.d[i]=a.d[i]%10;
	}
	a.len=i;
	return ;
}
int main()
{
	int i,j,k,temp;
	char st[80];
	num a,b;
	while(scanf("%s",st)!=EOF)
	{
		a.len=b.len=strlen(st);
		for(i=a.len-1;i>=0;i--)
			a.d[i]=b.d[i]=st[a.len-i-1]-'0';
		for(i=1;i<b.len;i++)
		{
			addhigh(a,b);
			if(a.len!=b.len)
			{
				printf("%s is not cyclic\n",st);
				break;
			}
			else
			{
				for(j=0;j<a.len;j++)
				{
					for(k=0;k<a.len;k++)
					{
						temp=(k+j)%a.len;
						if(a.d[temp]!=b.d[k])
							break;
					}
					if(k==a.len)
						break;
				}
				if(j==a.len)
				{
					printf("%s is not cyclic\n",st);
					break;
				}
			}
		}
		if(i==b.len)
			printf("%s is cyclic\n",st);
	}
	return 0;
}		
/*
142857
0588235294117647
052631578947368421
0434782608695652173913
0344827586206896551724137931
0212765957446808510638297872340425531914893617
0169491525423728813559322033898305084745762711864406779661
016393442622950819672131147540983606557377049180327868852459
01
758241
0588235294117646
152631578947368421
04347826086956521739130
034482758620689655172413793
0212765957446808501638297872340425531914893617
0169491525423728813559322033898305084745762711864406779666
485767305968737584736478947631110239847564719283674623819109
999999999999999999999999999999999999999999999999999999999999
*/

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