Cup

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 8942    Accepted Submission(s): 2744

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
 
Source
 
Recommend
分析:二分,对高度进行二分,然后我们知道圆台的公式为V=pi/3*(r*r+u*u+r*u)*h;然后可二分解决!这题精度比较坑爹,所以稍微注意点就好了!
下面给出AC代码:
 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
int x=,f=;
char ch=getchar();
while(ch<''||ch>'')
{
if(ch=='-')
f=-;
ch=getchar();
}
while(ch>=''&&ch<='')
{
x=x*+ch-'';
ch=getchar();
}
return x*f;
}
inline void write(int x)
{
if(x<)
{
putchar('-');
x=-x;
}
if(x>)
{
write(x/);
}
putchar(x%+'');
}
const double pi=acos(-1.0);
const double eps=1e-;
double r,R,h,H,V;
inline double check(double r,double R,double h,double H)
{
double u=h/H*(R-r)+r;
return pi*1.0*(r*r+u*u+u*r)*h/;
}
int main()
{
int n;
n=read();
while(n--)
{
scanf("%lf%lf%lf%lf",&r,&R,&H,&V);
double L1=0.0;
double R1=100.0;
double mid;
while(L1+eps<R1)
{
mid=(L1+R1)/;
double vv=check(r,R,mid,H);
if(fabs(vv-V)<=eps)
break;
else if(vv>V)
R1=mid-eps;
else L1=mid+eps;
}
printf("%.6lf\n",mid);
}
return ;
}

HDU 2289 Cup【高精度,二分】的更多相关文章

  1. HDU 2289 Cup【二分】

    <题目链接> 题目大意: 一个圆台型的杯子,它的上底半径和下底半径已经给出,并且给出它的高度,问你,体积为V的水倒入这个杯子中,高度为多少. 解题分析: 就是简单的二分答案,二分枚举杯中水 ...

  2. HDU 2289 CUP 二分

    Cup Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...

  3. hdu 2289 Cup (二分法)

    http://acm.hdu.edu.cn/showproblem.php?pid=2289 二分法解题. 这个题很恶心...一开始测试样例都不能过,这个π一开始取3.1415926结果是99.999 ...

  4. HDU 2289 Cup

    Cup Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...

  5. HDU 2289 Cup(可以二分法,但是除了它的一半?)

    这道题目.运营商做数学题?算上两个子主题做?顶多算一个水主要议题... 首先,没有实际的二分法,但是,我们发现了一个新的解决方案,以取代二分法. 若果按照i从0,每次添加0.00000001我一直枚举 ...

  6. Hdoj 2289.Cup 题解

    Problem Description The WHU ACM Team has a big cup, with which every member drinks water. Now, we kn ...

  7. POJ 2109 Power of Cryptography【高精度+二分 Or double水过~~】

    题目链接: http://poj.org/problem?id=2109 参考: http://blog.csdn.net/code_pang/article/details/8263971 题意: ...

  8. 二分搜索 HDOJ 2289 Cup

    题目传送门 /* 二分搜索:枚举高度,计算体积与给出的比较. */ #include <cstdio> #include <algorithm> #include <cs ...

  9. hdu 2289 要二分的杯子

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2289 大意是 一个Cup,圆台形,给你它的顶部圆的半径,底部圆的半径,杯子的高度,和此时里面装的水的体 ...

随机推荐

  1. awk 字符拼接

    i-6gdkkemx 2 2 #cat cpu.txt | awk '{print $1,$2"核"$3"G"}' i-6gdkkemx 2核2G

  2. Oracle11g不能导出空表问题

    ORACLE 11g 用exp命令导出库文件备份时,发现只能导出来一部分表而且不提示错误,之前找不到解决方案只能把没导出来的表重新建建立.后来发现是所有的空表都没有导出来.于是想好好查查,因为在以前的 ...

  3. 快速学习Bash

    作者:Vamei 出处:http://www.cnblogs.com/vamei 严禁转载. Shell是Linux下经典的文本互动方式,而Bash是现在最常用的一种Shell.我在这里总结了Bash ...

  4. Simple Games Using SpriteKit

    p.p1 { margin: 0.0px 0.0px 12.0px 0.0px; line-height: 14.0px; font: 12.0px Times; color: #000000 } s ...

  5. PE格式第三讲扩展,VA,RVA,FA(RAW),模块地址的概念

    PE格式第三讲扩展,VA,RVA,FA的概念 作者:IBinary出处:http://www.cnblogs.com/iBinary/版权所有,欢迎保留原文链接进行转载:) 一丶VA概念 VA (vi ...

  6. Xamarin android spinner的使用方法

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  7. ArcGIS 网络分析[4] 网络数据集深入浅出之连通性、网络数据集的属性及转弯要素

    前面介绍完了如何创建网络数据集.如何使用网络分析功能,当然还有的读者会迷惑于一些更深层次的问题,比如网络数据集的连通性问题等. 因为不可能面面俱到,我只能挑重点来阐述,我觉得网络数据集的连通性.属性和 ...

  8. 视觉SLAM

    SLAM:Simultaneous Localization And Mapping.中文:同时定位与地图重建. 它是指搭载特定传感器的主体,在没有实验先验信息的情况下,于运动过程中建立环境的模型,同 ...

  9. HBase0.98使用ReplicationAdmin管理集群同步

    公司datalink平台负责从各种数据源读取数据并同步到其他的同步或者异构数据源,最近增加的HBase的reader利用到了Hbase的Replication特性. 正常情况下,我们配置HBase的R ...

  10. Docker(四):Docker基本网络配置

    1.Libnetwork Libnetwork提出了新的容器网络模型简称为CNM,定义了标准的API用于为容器配置网络. CNM三个重要概念: 沙盒:一个隔离的网络运行环境,保存了容器网络栈的配置,包 ...