| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:用二分过了,不过精度用得太高了,1e-12,pi用3.1415926535897932324626。。。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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator