前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >HDUOJ-------2493Timer(数学 2008北京现场赛H题)

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

作者头像
Gxjun
发布2018-03-22 13:34:30
5850
发布2018-03-22 13:34:30
举报
文章被收录于专栏:mlml

Timer

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

Problem Description

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.

Input

The first line of the input contains an integer T(1<=T<=20), indicating the number of test cases. Each line after that is a test case. It contains three real numbers, H, D(1<=H,D<=1000) and V, indicating the height and bottom diameter of the timer, and the volume of water that flew out during the ceremony. That volume is guaranteed to be less than half volume of the container.

Output

For each test case, output one line containing the height of the sacred line above the ground. You should round off the answers to the 5th decimal place. (For example, rounding off 4.000005 equals to 4.00001 and rounding off 4.000004 equals to 4.00000)

Sample Input

2 5.0 10.0 0.0 5.0 10.0 65.4498

Sample Output

10.00000 5.00000

Source

2008 Asia Regional Beijing

数学题: 看了结题报告做的

代码:

代码语言:javascript
复制
 1 #include<stdio.h>
 2 #include<stdlib.h>
 3 #include<math.h>
 4 const double ZERO =1e-8 ;
 5 double H,D,V,R;
 6 double calc(double r)
 7 {
 8     double h=R-r;
 9     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;
10 }
11 int main()
12 {
13     int cases =0;
14     double l,r,mid;
15     scanf("%d",&cases);
16     while(cases--)
17     {
18         scanf("%lf%lf%lf",&H,&D,&V);
19         R=D/2.0;
20         l=0; r=R;
21         while(r-l>=ZERO)
22         {
23             mid=(l+r)/2;
24             if(calc(mid)<V) l=mid;
25             else r=mid;
26         }
27         printf("%.5lf\n",2*R-(l+r)/2.0);
28     }
29     return 0;
30 }
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2014-05-26 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Timer
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档