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

一般来说,我用的pi不会少过20位小数,能用牛迭就尽量用

Posted by frkstyc at 2005-07-06 00:51:02 on Problem 1905
In Reply To:用了double,3.1415926,还是WA,无法理解,请指点一下 Posted by:sunmoonstar_love at 2005-07-06 00:49:31
> 
>          基本思路就是二分法逼近,代码不长
>          请各位给些意见
> 
> #include <cstdio>
> #include <cmath>
> //#include <iostream>
> using namespace std;
> int main()
> {
>     double l,n,c,t,u,d,r,l1,angle,tmp;
>     while(scanf("%lf%lf%lf",&l,&n,&c)&& (l!=-1))
>     {
>         if(n==0.00) 
>         { 
>             printf("%.3lf\n",0); 
>             continue; 
>         }  
>         l1 = l*(1+n*c);
>         tmp = l/l1;
>         u = 3.1415926*6/7;
>         d = 0;
>         while(fabs(u-d)>0.000000000001)
>         {
>         //这个函数是单调的,所以用二分法逼近
>             angle = (u+d)/2;t = sin(angle)/angle;
>             if(fabs(t-tmp)<0.0000000000000001)
>                break;
>             if(t>tmp)
>                 d = angle;
>             else
>                 u = angle;
>         }
>       //  r = l1/2/angle;
>     //    tmp = r*(1-cos(angle));
>     //    printf("%.3lf\n",l1/angle/2*(1-cos(angle)));
>         printf("%.3lf\n",l1/angle/2*(1-cos(angle)));    
>     }    
>     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