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

为什么!为什么PE!

Posted by Manio at 2006-02-16 22:00:32 on Problem 1140
main()
{
int a ,b ,yushu[1200] ,r ,i ,j;
int find;

scanf("%d%d",&a,&b);

while( a != 0 && b != 0)
{
yushu[0] = a;
printf(".");
i = 1;
find = 0;
	while(1)
	{
	r = yushu[i-1]*10/b;
	yushu[i] = yushu[i-1]*10%b;
	printf("%d",r);

	if(yushu[i]==0)
	{
		find = 2;
		break;
	}

	for( j = 0 ; j < i ; j++)
	{
		if(yushu[j]==yushu[i])
		{
			find = 1;
			break;
		}
	}

	if(find==1 || find==2)break;
	if(i%49==0)printf("\n");
	i++;
	}/*inside while*/
	if(find==1)
	{
		printf("\nThe last %d digits repeat forever.\n",i-j);
	}else{
		printf("\nThis expansion terminates.\n");
	}
scanf("%d%d",&a,&b);

}/*while*/

}/*main*/

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