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:why pe????

Posted by zwf at 2005-08-04 23:51:25 on Problem 1140
In Reply To:why pe???? Posted by:zwf at 2005-08-04 23:50:56
code:
#include<stdio.h>
int main()
{int i,j,a,b,c[1001],find,A;
while(1)
{
	scanf("%d%d",&a,&b);
	if (a==0&&b==0) break;
	i=1;find=0;
   c[1]=a;  printf(".");
   while(c[i]!=0&&i<=b)
  {
    A=c[i]*10/b;
    c[i+1]=c[i]*10%b;
    printf("%d",A);
	if((i+1)%50==0) printf("\n");
    for(j=1;j<=i;j++)
    {
     if(c[j]==c[i+1])
     {find=1;break;}
    }
    if(find==1) break;
    i++;
  }
 if(find)  printf("\nThe last %d digits repeat forever.\n",(i+1-j));
  else      printf("\nThis expansion terminates.\n");
  }
  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