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.

2. 1 ≤ r, R, H ≤ 100; 0 ≤ V ≤ 1000,000,000.

3. r ≤ R.

4. r, R, H, V are separated by ONE whitespace.

5. 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
#include<stdio.h>
#include<math.h>
#define e 0.0000001
#define PI acos(-1.0)
double V,r,H,R,h;
double cc(double x,double th)
{
return PI*th*(x*x+x*r+r*r)/3.0;
}
void ccc(double ans)
{
double m,l,ri;
l=0;ri=100.0;
while(l+e<ri)
{
m=(l+ri)/2.0;
if(cc(r+m*(R-r)/H,m)>ans)ri=m;
else l=m;
}
h=m;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf%lf%lf",&r,&R,&H,&V);
ccc(V);
printf("%.6lf\n",h);
}
}

 

hdu2289Cup(神坑题,精度+二分,以半径二分不能过,以高度为二分就过了)的更多相关文章

  1. POJ 1064 Cable master(二分查找+精度)(神坑题)

    POJ 1064 Cable master 一开始把 int C(double x) 里面写成了  int C(int x) ,莫名奇妙竟然过了样例,交了以后直接就wa. 后来发现又把二分查找的判断条 ...

  2. bzoj千题计划316:bzoj3173: [Tjoi2013]最长上升子序列(二分+树状数组)

    https://www.lydsy.com/JudgeOnline/problem.php?id=3173 插入的数是以递增的顺序插入的 这说明如果倒过来考虑,那么从最后一个插入的开始删除,不会对以某 ...

  3. PAT甲题题解-1115. Counting Nodes in a BST (30)-(构建二分搜索树+dfs)

    题意:给出一个序列,构建二叉搜索树(BST),输出二叉搜索树最后两层的节点个数n1和n2,以及他们的和sum: n1 + n2 = sum 递归建树,然后再dfs求出最大层数,接着再dfs计算出最后两 ...

  4. 二分求解 三角形 stl的应用 涉及范围的二分查找可以先求上界再算下界,结果即上界减下界

     二分 Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu   Description You ...

  5. 【noip模拟题】挖掘机(模拟题+精度)

    这题直接模拟. 可是我挂在了最后两个点上QAQ.唯一注意的是注意精度啊...用来double后边转成整数就忘记用longlong...sad #include <cstdio> #incl ...

  6. JavaScript学习笔记6 之经典神坑题整理

    本篇内容是关于容易出错题的整理,这些题也有利于对javascript的语法逻辑的理解,分析的内容仅供参考: <script> */ var x=0 , y=0 , c=1; functio ...

  7. HDU5127 神坑题---vector 、 list 、 deque 的用法区别

    题意:三个操作 1  a b : 队列中加入(x = a, y = b); -1  a b : 队列中减去(x = a, y = b); 0  p q :从队列的数对中查询哪一对x,y能够让 p * ...

  8. July 【补题】

    A(zoj 3596) bfs,记忆搜都可以, 按余数来记录状态. B(zoj 3599) 博弈,跳过 C(zoj 3592) 简单dp,题意不好懂 D(zoj 3602) 子树哈希, 对根的左右儿子 ...

  9. [Codeforces 460C] Present

    [题目链接] https://codeforces.com/contest/460/problem/C [算法] 二分 + 贪心 要求最小值最大 , 我们不妨二分最小值 , 若一盆花的高度小于二分的值 ...

随机推荐

  1. Cloudera Manager Service Monitor 定期挂掉问题排查

    显示:查询 Service Monitor 时发生内部错误(Error sending messages to firehose: mgmt-SERVICEMONITOR-) 1.初步排查出是smon ...

  2. Oracle系统视图

    VIEW TABLES 1.DBA_TABLES --查看系统里所有表的信息,只有DBA权限用户才可查看 SELECT * FROM DBA_TABLES WHERE OWNER='HR' AND T ...

  3. IOS 学习笔记(4) 控件 标签(UILabel)的使用方法

    虽说Label的中文翻译是标签标记,但它其实是一个静态文本内容的展现控件. 一般来说,UILabel只是一个只读的文本视图,开发者可以利用UiLabel来展示内容长度有固定上限的文字内容.并且,UIL ...

  4. JQuery 限制文本框只能输入数字和小数点

    $(function(){ /*JQuery 限制文本框只能输入数字*/ $(".NumText").keyup(function(){ $(this).val($(this).v ...

  5. Oracle中SQL语句学习五(统计分组语句group by和having)

    oracle(41) 在 应用系统开发中,进行需要统计数据库中的数据,当执行数据统计时,需要将表中的数据进行分组显示,在统计分组中是通过group by子句.分组函数.having子句共同实现的.其中 ...

  6. Qt 智能指针学习(7种QT的特有指针)

    从内存泄露开始? 很简单的入门程序,应该比较熟悉吧 ^_^ #include <QApplication> #include <QLabel> int main(int arg ...

  7. android天气查询(一)websevice之ksoap2软件包的使用

    对于用到天气信息,首先我想: 第一:数据不可能是我测得的,必须是网上的信息. 第二:网上的信息分为好多种,具体哪种比较好一点,这里我总结了两种. 第三:数据JSON怎么解析. 第四:如何提出数据与显示 ...

  8. android 大小写转换

    private void toUpperCase(byte[] data, int start, int len) { int end = start + len; int dist = 'A' - ...

  9. perl5 第一章 概述

    第一章 概述 by flamephoenix 一.Perl是什么?二.Perl在哪里?三.运行四.注释 一.Perl是什么?      Perl是Practical Extraction and Re ...

  10. HDU 2215 Maple trees

    增量法的最小包围圈算法,不会…… #include <cstdio> #include <cstring> #include <iostream> #include ...