Cup
Cup |
| Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) |
| Total Submission(s): 932 Accepted Submission(s): 319 |
|
Problem Description
The WHU ACM Team has a big cup, with which every member drinks water. Now, we know the volume of the water in the cup, can you tell us it height?
The radius of the cup's top and bottom circle is known, the cup's height is also known. |
|
Input
The input consists of several test cases. The first line of input contains an integer T, indicating the num of test cases.
Each test case is on a single line, and it consists of four floating point numbers: r, R, H, V, representing the bottom radius, the top radius, the height and the volume of the hot water. Technical Specification 1. T ≤ 20. |
|
Output
For each test case, output the height of hot water on a single line. Please round it to six fractional digits.
|
|
Sample Input
1 |
|
Sample Output
99.999024 |
|
Source
The 4th Baidu Cup final
|
|
Recommend
lcy
|
/*
一晚上把底半径和二分的右区间变量名用重了,还看出来,真是.....
*/
#include<bits/stdc++.h>
#define op 1e-9
#define pi acos(-1.0)
using namespace std;
/*
V=π×h×(R2﹢R×r﹢r2)/3
*/
double S(double r,double R,double h,double H)//圆台面积
{
double r1=r+h*(R-r)/H;
return pi*h*(r1*r1+r1*r+r*r)/;
}
int main()
{
//freopen("C:\\Users\\acer\\Desktop\\in.txt","r",stdin);
int t;
double left,right,h,v;
double r,R,H,V;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf%lf%lf",&r,&R,&H,&V);
//cout<<r<<" "<<R<<" "<<H<<" "<<(int )V<<endl;
left=,right=;
while(right-left>op)
{
//cout<<h<<endl;
h=(right+left)/;
v=S(r,R,h,H);
//cout<<v<<endl;
if(fabs(v-V)<=op)
break;
else if(v>V)
right=h-op;
else
left=h+op;
}
printf("%.6lf\n",h);
}
return ;
}
Cup的更多相关文章
- java高cup占用解决方案
项目中发现java cpu占用高达百分之四百,查看代码发现有一个线程在空转,拉高了cup while(true){ } 解决方案,循环中加入延迟:Thread.sleep(Time): 总结下排查CP ...
- UVALive 7147 World Cup(数学+贪心)(2014 Asia Shanghai Regional Contest)
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=6 ...
- uva 6757 Cup of Cowards(中途相遇法,貌似)
uva 6757 Cup of CowardsCup of Cowards (CoC) is a role playing game that has 5 different characters (M ...
- 【转】关于KDD Cup '99 数据集的警告,希望从事相关工作的伙伴注意
Features From: Terry Brugger Date: 15 Sep 2007 Subject: KDD Cup '99 dataset (Network Intrusion) cons ...
- Facebook Hacker Cup 2014 Qualification Round 竞赛试题 Square Detector 解题报告
Facebook Hacker Cup 2014 Qualification Round比赛Square Detector题的解题报告.单击这里打开题目链接(国内访问需要那个,你懂的). 原题如下: ...
- DP VK Cup 2012 Qualification Round D. Palindrome pairs
题目地址:http://blog.csdn.net/shiyuankongbu/article/details/10004443 /* 题意:在i前面找回文子串,在i后面找回文子串相互配对,问有几对 ...
- [BZOJ 3145][Feyat cup 1.5]Str 解题报告
[Feyat cup 1.5]Str DescriptionArcueid,白姬,真祖的公主.在和推倒贵看电影时突然对一个问题产生了兴趣:我们都知道真祖和死徒是有类似的地方.那么从现代科学的角度如何解 ...
- HDU 2289 CUP 二分
Cup Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...
- VK Cup 2012 Round 3 (Unofficial Div. 2 Edition)
VK Cup 2012 Round 3 (Unofficial Div. 2 Edition) 代码 VK Cup 2012 Round 3 (Unofficial Div. 2 Edition) A ...
- UVALive 7275 Dice Cup (水题)
Dice Cup 题目链接: http://acm.hust.edu.cn/vjudge/contest/127406#problem/D Description In many table-top ...
随机推荐
- bootstrap 表单样式
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- SqlHelper工具类
public class SqlHlper { public static readonly string constr = ConfigurationManager.ConnectionString ...
- Vuex 学习笔记
Vuex 是什么? Vuex 是一个专为 Vue.js应用程序开发的状态管理模式.由于SPA应用的模块化,每个组件都有它各自的数据(state).视图(view)和方法(actions),当项目内容越 ...
- ADALINE模型
ADALINE模型即自适应线性单元(Adaptive Linear Neuron),主要用于信号处理中的自适应滤波.预测和模式识别.其结构图如下 输入向量X=(x0,x1,x2,...,xn)T每个输 ...
- 【POJ】3090 Visible Lattice Points(欧拉函数)
Visible Lattice Points Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7705 Accepted: ...
- FastDFS的安装步骤
1.安装相关环境 yum install -y gcc-c++ yum -y install libevent yum install -y pcre pcre-devel yum install - ...
- PHP 两张图片合成一张图片(加水印)
$dst_im = 'http://www.wangshangyou.com/content/uploadfile/201312/b3241386050881.png'; $src_im = 'htt ...
- vuejs2+axios设置
http://www.cnblogs.com/wisewrong/p/6402183.html 1 当前项目安装axios $ cnpm i axios --save-dev 2 import axi ...
- 用$.getJSON() 和$.post()获取第三方数据做页面 ——惠品折页面(1)
用$.getJSON() 和$.post()获取第三方数据做页面 首页 index.html 页面 需要jquery 和 template-web js文件 可以直接在官网下载 中间导航条的固 ...
- jsp 四大域范围
JSP中四种作用域的不同 作用域规定的是变量的有效期限. 1.如果把变量放到pageContext里,就说明它的作用域是page,它的有效范围只在当前jsp页面里. 从把变量放到pageCont ...