hdu2289 CUP

来源:互联网 发布:看不见的战争 知乎 编辑:程序博客网 时间:2024/05/29 13:02

1003.CUP

给你一个圆台行的杯子的上下圆半径和高度(可能是圆柱),和里面的水的体积,求水的高度。数学题,算出公式即可。


#include<cstdio>#include<cmath>const double pi=4*atan(1.0);int main(){    int t;    scanf("%d",&t);    while (t--)    {        double r,R,H,V,ans;        scanf("%lf%lf%lf%lf",&r,&R,&H,&V);        if (R!=r)        {            double x=r*H/(R-r);            double v1=pi*r*r*x/3;            ans=pow((V+v1)/v1,1/3.0)*x-x;        }        else ans=V/(pi*R*R);        if (ans>H) ans=H;        printf("%.6lf\n",ans);    }    return 0;}


0 0
原创粉丝点击