标签:else ted chm lan read while tchar sea bottom
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 8942 Accepted Submission(s): 2744
1 #include <bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 inline int read() 5 { 6 int x=0,f=1; 7 char ch=getchar(); 8 while(ch<‘0‘||ch>‘9‘) 9 { 10 if(ch==‘-‘) 11 f=-1; 12 ch=getchar(); 13 } 14 while(ch>=‘0‘&&ch<=‘9‘) 15 { 16 x=x*10+ch-‘0‘; 17 ch=getchar(); 18 } 19 return x*f; 20 } 21 inline void write(int x) 22 { 23 if(x<0) 24 { 25 putchar(‘-‘); 26 x=-x; 27 } 28 if(x>9) 29 { 30 write(x/10); 31 } 32 putchar(x%10+‘0‘); 33 } 34 const double pi=acos(-1.0); 35 const double eps=1e-9; 36 double r,R,h,H,V; 37 inline double check(double r,double R,double h,double H) 38 { 39 double u=h/H*(R-r)+r; 40 return pi*1.0*(r*r+u*u+u*r)*h/3; 41 } 42 int main() 43 { 44 int n; 45 n=read(); 46 while(n--) 47 { 48 scanf("%lf%lf%lf%lf",&r,&R,&H,&V); 49 double L1=0.0; 50 double R1=100.0; 51 double mid; 52 while(L1+eps<R1) 53 { 54 mid=(L1+R1)/2; 55 double vv=check(r,R,mid,H); 56 if(fabs(vv-V)<=eps) 57 break; 58 else if(vv>V) 59 R1=mid-eps; 60 else L1=mid+eps; 61 } 62 printf("%.6lf\n",mid); 63 } 64 return 0; 65 }
标签:else ted chm lan read while tchar sea bottom
原文地址:http://www.cnblogs.com/ECJTUACM-873284962/p/7133053.html