标签:
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 7077 Accepted Submission(s): 2177
1 #include <cstdio> 2 #include <cmath> 3 4 const double PI = acos(-1.0); 5 int T; 6 double r,R,H,V; 7 8 int main() 9 { 10 scanf("%d", &T); 11 while(T--){ 12 scanf("%lf%lf%lf%lf", &r, &R, &H, &V); 13 double low = 0, high = H; 14 double mid; 15 while(high-low>1e-8){ 16 mid = (low+high)/2; 17 double mid_r = mid/H*(R-r)+r; 18 double mid_v = PI/3*mid*(r*r+r*mid_r+mid_r*mid_r); 19 if(mid_v<V) 20 low = mid+1e-8; 21 else 22 high = mid-1e-8; 23 } 24 mid = (low+high)/2; 25 printf("%.6f\n", mid); 26 } 27 return 0; 28 }
标签:
原文地址:http://www.cnblogs.com/inmoonlight/p/5553772.html