Qiuqiqiu  
不管道路多么崎岖坎坷,我永远不停下追逐梦想的脚步!

http://acm.hdu.edu.cn/showproblem.php?pid=2289

我的代码
 1 #include <stdio.h>
2 #include <math.h>
3 double r1,r2,h,v;
4 const double pi=acos(-1.0),esp=1e-9;
5 double f(double x)
6 {
7 double r=(r2-r1)*x/h+r1;
8 return (r1*r1+r*r+r1*r)*pi*x/3;
9 }
10 int main()
11 {
12 int T;
13 double l,r,m;
14 scanf("%d",&T);
15 while (T--)
16 {
17 scanf("%lf%lf%lf%lf",&r1,&r2,&h,&v);
18 l=0; r=h;
19 while (fabs(l-r)>esp)
20 {
21 m=(l+r)/2;
22 if (v<f(m)) r=m;
23 else l=m;
24 }
25 printf("%.6lf\n",l);
26 }
27 }

 

posted on 2011-12-10 15:12  Qiuqiqiu  阅读(170)  评论(0编辑  收藏  举报