poj 1905 Expanding Rods 二分

 1 /**
 2 题解晚上写
 3 **/
 4 #include <iostream>
 5 #include <math.h>
 6 #include <algorithm>
 7 #include <cstdio>
 8 using namespace std;
 9 const double esp = 1e-5;
10 int main()
11 {
12     double l,n,c;
13     while(cin>>l>>n>>c){
14         if(l<0&&n<0&&c<0)
15             break;
16         double ll;
17         ll = (1+n*c)*l;
18         double low,high;
19         low =0;
20         high= l/2;
21         double r,mid;
22         while(high-low>esp){
23             mid = (high+low)/2.0;
24             r = ((mid*mid*4)+(l*l))/(8*mid);
25             if(2*r*asin(l/(2*r))<ll)
26                 low = mid;
27             else
28                 high = mid;
29         }
30         printf("%.3lf\n",high);
31     }
32     return 0;
33 }

 

posted @ 2014-05-12 20:37  夜晓楼  阅读(176)  评论(0编辑  收藏  举报