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. mysql 创建表字段类型笔记

    1.字段联合唯一,unique(ServerVersion , MobileVersion, MobileType) .并且mysql设置多个字段为主键是起不到约束唯一的作用. 2.二进制用 BLOB ...

  2. c 语言简单计算器源码

    //  main.c //  计算器 //  Created by qianfeng on 14-7-15. //  Copyright (c) 2014年 ___FGY___. All rights ...

  3. 项目管理软件伙伴https://www.huobanyun.cn/

    现在项目管理软件市面上很多,但能够完全适合每家公司需求的比较难找,因为众口难调,每家公司都有自己的特殊情况,所以,建议考虑下有比较齐全的基础功能的标准化软件产品,同时又在项目管理开发能力上比较突出. ...

  4. 射频识别技术漫谈(26)——Felica的文件系统

    Felica的文件系统使用“系统\域\服务\数据块”的结构,如下图所示.通过这种结构实现对卡片非易失性存储区的使用和操作.                                     Fe ...

  5. Python单元测试:unittest使用简介

    一.概述 本文介绍python的单元测试框架unittest,这是Python自带的标准模块unittest.unittest是基于java中的流行单元测试框架junit设计的,其功能强大且灵活,对于 ...

  6. HDU题解索引

    HDU 1000 A + B Problem  I/O HDU 1001 Sum Problem  数学 HDU 1002 A + B Problem II  高精度加法 HDU 1003 Maxsu ...

  7. Sicily-1153 解题报告

    一.原题中文大意. 1      2       3      4       5      6         7     8 9     10       11    12      13    ...

  8. Python+Django+SAE系列教程9-----Django的视图和URL

    第三.四.五章介绍的就是Django中MVC的视图.模板.模型了. 首先来看视图(view),在用Django生成的站点目录中,创建一个view.py文件,这个文件開始是空的.然后我们输入下面内容: ...

  9. hadoop学习;安装jdk,workstation虚拟机v2v迁移;虚拟机之间和跨物理机之间ping网络通信;virtualbox的centos中关闭防火墙和检查服务启动

    JDK 在Ubuntu下的安装 与 环境变量的配置 前期准备工作: 找到  JDK 和 配置TXT文件  并拷贝到桌面下  不是目录 而是文件拷贝到桌面下 以下的命令部分就直接复制粘贴就能够了 1.配 ...

  10. Delete website with command.

    1.AppCmd.exe 2.http://www.windowsnetworking.com/articles-tutorials/windows-server-2008/Configuring-I ...