标签:
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2237 Accepted Submission(s):
859
1 #include<stdio.h> 2 #include<math.h> 3 #define PI 3.1415926535 4 double l,d,x,y; 5 double hs(double p) 6 { 7 double w; 8 w=l*sin(p)-x*tan(p)+d/cos(p);//函数,计算h 9 return w; 10 } 11 int main() 12 { 13 while(scanf("%lf%lf%lf%lf",&x,&y,&l,&d)!=EOF) 14 { 15 double a=0,b=PI/2,mid,midmid; 16 do 17 { 18 //mid=(b-a)/3+a; 19 //midmid=(b-a)*2/3+a; 20 mid=(a+b)/2; 21 midmid=(mid+b)/2; 22 if(hs(mid)>hs(midmid)) 23 b=midmid; 24 else 25 a=mid; 26 }while(b-a>1e-10); 27 if(hs(mid)<y) 28 printf("yes\n"); 29 else 30 printf("no\n"); 31 } 32 return 0; 33 }
标签:
原文地址:http://www.cnblogs.com/Eric-keke/p/4679082.html