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:AC代码在那里找的,给给网站好吗?

Posted by 153220053 at 2007-08-03 15:50:51 on Problem 1079
In Reply To:求助,帮忙找错,一直wa Posted by:zhj5825 at 2006-06-29 15:22:02
> 这道题已经做了很长时间了,而且也看过别人AC的代码,但是仍然找不到自己的错误,而且一直WA。哪位同学能帮忙给看看,非常感谢~
> ——————————————————————————————————————————————
> #include<stdio.h>
> #include<math.h>
> 
> main()
> {
>   int gain,lose,fenzi,fenmu,gcd,flag=0;
>   while (scanf("%d %d",&gain, &lose)!=EOF)
>   {
>     double result,temp,chazhi=0,min=1;
>     result=(double)gain/lose;
>   
>     for (fenmu=1;fenmu<=lose;fenmu++)
>     {
>         fenzi=(int)(fenmu*(result));
>         if (fenmu==1)
>             if ((round(result))>result)
>                 fenzi=(int)round(result);
> 
>         while(flag==0)
>         {
>             temp=(double)fenzi/fenmu;
>             chazhi=fabs(temp-result);
>             if (min>chazhi)
>             {
>                 min=chazhi;
>                 printf("%d/%d\n",fenzi,fenmu);
>                 break;
>              }
>                 fenzi++;   
>             if (chazhi>1)
>                 flag=1;
>         }  
>         flag=0;       
>     }
>     printf("\n");
>    }    
> }

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