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

你的float,你的3.14都是大问题

Posted by frkstyc at 2005-07-05 23:32:05 on Problem 1905
In Reply To:用二分法做的,但总是WA,兄弟们帮看看 Posted by:sunmoonstar_love at 2005-07-05 23:21:38
> #include <stdio.h>
> #include <math.h>
> 
> int main()
> {
>     float l,n,c,t,u,d,r,l1,angle,tmp;
>     while(scanf("%f%f%f",&l,&n,&c)&& (l!=-1))
>     {
>         l1 = l*(1+n*c);
>         tmp = l/l1;
>         u = 3.14*3/4;
>         d = 0;
>         while(fabs(u-d)>0.000000000001)
>         {
>             angle = (u+d)/2;t = sin(angle)/angle;
>             if(fabs(t-tmp)<0.00000000001)
>                break;
>             if(t>tmp)
>                 d = angle;
>             else
>                 u = angle;
>         }
>         r = l1/2/angle;
>         tmp = r*(1-cos(angle));
>         printf("%.3f\n",tmp);    
>     }    
>     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