您的位置:首页 > 其它

HDUOJ-------2493Timer(数学 2008北京现场赛H题)

2014-05-26 10:20 239 查看

Timer

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 445 Accepted Submission(s): 90

[align=left]Problem Description[/align]
Recently, some archaeologists discovered an ancient relic on a small island in the Pacific Ocean. In the relic, they found an interesting cone shaped container with transparent bottom. The container lay on the horizontal ground with its central axis parallel to the ground. Just beside the container, they found a manual telling them something about the container.
The container was a timer for a special ceremony. Ancient people filled it all with water before the ceremony, and when the ceremony began, they pulled out the plug in the small hole on the tip of the cone to let the water out. There was a horizontal line called “sacred line” carved on the bottom of the cone, and when the water level hit that line, they pushed the plug back and ended the ceremony. But the archaeologists could not found the sacred line on that cone. In order to sell the timer at a good prize, the archaeologists wanted to recover that very important line.
By the manual they figured out how much water flew out when the ceremony ended, but they don’t know what to do next, so they come to you for help.
They measures the height of the cone, and the diameter of the bottom, you should tell them the sacred line’s height above the ground.

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
const double ZERO =1e-8 ;
double H,D,V,R;
double calc(double r)
{
double h=R-r;
return H*R*R*acos(h/R)/3 -h*H*sqrt(R*R-h*h)*2/3+h*h*h*H/R*log((R+sqrt(R*R-h*h))/h)/3;
}
int main()
{
int cases =0;
double l,r,mid;
scanf("%d",&cases);
while(cases--)
{
scanf("%lf%lf%lf",&H,&D,&V);
R=D/2.0;
l=0; r=R;
while(r-l>=ZERO)
{
mid=(l+r)/2;
if(calc(mid)<V) l=mid;
else r=mid;
}
printf("%.5lf\n",2*R-(l+r)/2.0);
}
return 0;
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: