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 ...
随机推荐
- ng-model值字符串转数值型(convertToNumber directive)
<select ng-model="model.id" convert-to-number> <option value="0">Zer ...
- python基础之条件循环语句
前两篇说的是数据类型和数据运算,本篇来讲讲条件语句和循环语句. 0x00. 条件语句 条件语句是通过一条或多条语句的执行结果(True或者False)来决定执行的代码块. 可以通过下图来简单了解条件语 ...
- 9月24日noip模拟赛解题报告
1.校门外的树(tree.c/cpp/pas 128M,1s) Description LSGJ扩建了,于是校门外有了一条长为L的路.路上种了一排的树,每相邻两棵树之间的距离为1,我们可以把马路看成一 ...
- 安装myeclipse2015 stable 3.0破解之后发生出现SECURITY ALERT:iNTEGRITY CHECK ERROR然后闪退解决方案
安装好myeclipse2015 stable以后也一步步按着破解文件的步骤来进行.打开myEclipse---->Subscription information--->Subscrip ...
- stdafx.h 的作用
stdafx.h VC工程里面经常见到stdafx.h这个头文件,以前也没有特别注意,但是这个文件用不好经常会出错. stdafx的英文全称为:Standard Application Framewo ...
- Optional乱用Empty之No value present
前言 看到好多文章都是推荐采用Optinal的,而经常我遇到问题的时候就想:如果设计成optional的话就不会忽略这种NullPointException错误了.然而,optional并不是想用就随 ...
- java启动监听错误: org.springframework.web.context.ContextLoaderListener
项目启动会报以下错误: 解决方案如下: 感谢好心人的提示“其实可能是你的jar文件没有同步发布到自己项目的lib目录中(如果你是用Maven进行构建的话) 可以试试 下面的办法 项目点击右键 点击 P ...
- 轻量级文本编辑器,Notepad最佳替代品:Notepad++
目录 正文之前 1. 目的 2. 原帖 3. 为何推荐Notepad++ 3.1. Notepad++的一些基本特点 3.2. notepad,notepad2,notepad++,ultraEdit ...
- Kettle文本文件输出和输入控件使用中,换行符导致的问题处理
1.如下图通过输入控件从数据库读取数据然后生成TXT文本文件,TXT文件生成原则是每一条数据生成一行数据,第二条数据换行保存 2.如下图所示,使用文本文件输入控件读入上图生成的文件,文件读入原则是按行 ...
- windows下Maven的安装与配置
1 安装maven前首先确认计算机已正确安装JDK2 下载maven 地址:http://maven.apache.org/download.html安装文件格式如下:apache-maven-3.0 ...