HDUOJ-------2493Timer(数学 2008北京现场赛H题)
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
数学题: 看了结题报告做的
代码:
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("%.5lfn",2*R-(l+r)/2.0);
28 }
29 return 0;
30 }
- vue获取DOM元素并设置属性
- koa2入门学习
- 记一个node实现的图形验证码从0到1
- FHQ Treap小结(神级数据结构!)
- vuex在页面中以对象展开运算符形式引入报错解决
- 手机网页调用相机拍照或者图库
- P1903 【模板】分块/带修改莫队(数颜色)
- 前端如何获取http状态码400的返回值
- 不确定行数的多行文本垂直水平居中的css
- Vue slot简单理解
- css实现图片横向排列滚动
- windows下nvm安装node之后npm命令找不到问题解决办法
- 元素加了position:absolute则该元素的text-align:center居中失效的解决办法
- Chrome设置断点的各种姿势
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- 数据增强策略(一)
- 如何将pdf转换为word 3.0
- 搭建分布式文件系统FastDFS
- Presto Web UI
- Leetcode No.5 最长回文子串
- Python的循环、判断和各种表达式(长文系列第二篇)
- Java内存泄漏、性能优化、宕机死锁的N种姿势
- 从2.9秒到0.6秒,信息流首屏提效80%的秘诀
- 移植nodejs到嵌入式linux,让终端支持可使用js做些功能
- go语言版串口获取银商秘钥工具
- dotnet Microsoft.Recognizers.Text 超强大的自然语言关键词提取库
- Java 基础面试总结
- 银商TMS平台秘钥下载工具
- 小白向:Linux vim编辑器(一)
- 2020数据库面试题