标签:
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 5597 Accepted Submission(s): 1787
#include<queue> #include<math.h> #include<stdio.h> #include<string.h> #include<iostream> #include<algorithm> using namespace std; #define LL long long #define N 123456789 #define M 1234 const double PI = acos(-1.0); const double ee = 1e-8; double r,R,H,V,v; double calc(double h) { double x=r+h/H*(R-r); return PI*h*(r*r+x*x+r*x)/3; } int main() { int t;cin>>t; while(t--) { scanf("%lf%lf%lf%lf",&r,&R,&H,&V); double ll=0,rr=H,mid; while(ll<=rr) { mid=(ll+rr)/2; v=calc(mid); if(fabs(v-V)<=ee) break; else if(v<V) ll=mid+ee; else rr=mid-ee; } printf("%.6f\n",mid); } return 0; }
标签:
原文地址:http://www.cnblogs.com/wmxl/p/4738039.html