E - Cup
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
- T ≤ 20.
- 1 ≤ r, R, H ≤ 100; 0 ≤ V ≤ 1000,000,000.
- r ≤ R.
- r, R, H, V are separated by ONE whitespace.
- There is NO empty line between two neighboring cases.
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
100 100 100 3141562
Sample Output
99.999024
给你水杯的下上半径和高,在给你水的体积,求水高,二分一下就行,注意圆台的公式V=(1/3.0)πh(RR+rr+rR)
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iomanip>
#include<cmath>
#include<float.h>
#include<string.h>
#include<algorithm>
#define sf scanf
#define pf printf
#define pb push_back
#define mm(x,b) memset((x),(b),sizeof(x))
#include<vector>
#include<map>
#define for(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
typedef long double ld;
typedef double db;
const ll mod=1e12+100;
const db e=exp(1);
using namespace std;
const double pi=acos(-1.0);
db V,r,R,H;
int judge(db mid)
{
db rr=(R-r)*mid/H+r;
db v=(1/3.0)*pi*mid*(rr*rr+r*r+rr*r);
if(v==V) return 0;
if(v>V) return 1;
return -1;
}
int main()
{
int re;
cin>>re;
while(re--)
{
sf("%lf%lf%lf%lf",&r,&R,&H,&V);
db right=H,left=0,mid;
while(right-left>0.00000001)
{
mid=(left+right)/2;
if(judge(mid)==0)
break;
else if(judge(mid)>0)
right=mid;
else
left=mid;
}
pf("%.6lf\n",mid);
}
return 0;
}
E - 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 ...
随机推荐
- WPF如何为程序添加splashScreen(初始屏幕)
一.考虑到大部分的splashscreen其实都只是一个图片,所以最简单的做法是,先导入一张图片,然后设置它的生成操作为“splash screen” 二.通过程序设置SplashScreen pub ...
- 转 c#中stringbuilder的使用
String 对象是不可改变的.每次使用 System.String 类中的方法之一时,都要在内存中创建一个新的字符串对象,这就需要为该新对象分配新的空间.在需要对字符串执行重复修改的情况 ...
- 编写SHELL脚本--判断用户的参数
测试语句格式: [ 条件表达式 ] 常见的几种形式: [ -d /etc ] 判断/etc是不是一个目录类型, [ -e /etc/php.ini ] 判断/etc/php.ini 文件是否存在 [ ...
- 多网卡环境下Eureka服务注册IP选择问题
一.问题场景 服务器上分别配置了eth0, eth1和eth2三块网卡,只有eth1的地址可供其它机器访问,eth0和eth2的 IP 无效.在这种情况下,服务注册时Eureka Client会自动选 ...
- unity, 在image effect shader中用_CameraDepthTexture重建世界坐标
--------------更新 更简单的方法: //depth: raw depth, nonlinear, 0 at near plane, 1 at far plan float4 scre ...
- Windows Media Player 的文件格式支持情况
唔,官方文档:https://support.microsoft.com/zh-cn/help/316992/file-types-supported-by-windows-media-player ...
- How can R and Hadoop be used together?
Referer: http://www.quora.com/How-can-R-and-Hadoop-be-used-together/answer/Jay-Kreps?srid=OVd9&s ...
- python os详解
1.os.getcwd()--起始执行目录 获取当前执行程序文件所在的目录,需要注意的是,getcwd不是获取代码所在文件的目录,也不是获取执行文件所在的目录,而是起始执行目录. 目录结构: test ...
- 11款最轻量级的CSS框架
日子一去不复返了HTML用于造型的网页.今天,CSS规则,很难想象没有它的任何网页设计.CSS在最近非常先进,用于创建复杂的Web设计和风格.那么,我们为什么要使用CSS框架?答案很简单.CSS框架主 ...
- VS2013 未找到与约束ContractName Microsoft.VisualStudio.Text.ITextDocumentFactoryService
全是2012版本的 没找到2013的! 控制面板>程序>程序和功能 找到如下选中软件右击修复 即可 需关闭VS2013 参考:https://blog.csdn.net/zhaoyun9 ...