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 ...
随机推荐
- Socket编程的UDP与TCP,应用在哪些地方
随着网络技术飞速发展,网速已不再是传输的瓶颈,UDP协议以其简单.传输快的优势,在越来越多场景下取代了TCP,如网页浏览.流媒体.实时游戏.物联网. 1,网速的提升给UDP稳定性提供可靠网络保障 CD ...
- 【T05】套接字接口比XTI_TLI更好用
1.用于网络编程的API接口有两种: Berkeley套接字 XTL 2.套接字是加州大学伯克利分校为其Unix操作系统版本开发的,TLI是AT&T(贝尔实验室)为Unix系统V3.0开发的 ...
- PC端和移动端在前端开发上的一些区别,前端里移动端到底比pc端多哪些知识
(1)———————— 前端里移动端到底比pc端多哪些知识,为啥面试时好多公司都问h5水平如何?我做过几年的web前端开发,就简单谈谈自己的感受吧.首先来看看PC端和移动端在前端开发上的一些区别: ( ...
- 创建一个可拖动的DIV
var drag = function(){ var obj = document.getElementById("id"); var s = obj.style; var b = ...
- Centos7安装SVN服务器
1.关闭防火墙systemctl stop firewalld.service 2.安装svn服务器yum install subversion 3.创建放置项目project的地方mkdir /sv ...
- C#-MVC开发微信应用(8)--菜单管理的实现
之前讲解了微信后台管理页面的操作来管理菜单,下面我们在简单的来看一下,代码是如何实现的. 我们要实现获取微信的菜单.创建菜单.删除菜单等操作. 01.首先定义菜单操作的接口: /// <summ ...
- Ethereum Dapp Tutorial — Part 1
在上一篇文章中,通过和传统的 web程序相比较解释了以太坊平台的结构.作为一个开发者,学习新技术的最好的方式就是构建一个玩具程序. 在这篇文章中我们将会构建一个简单的“hello word”程序,这个 ...
- GraphQL,你准备好了么?
一个多月前,facebook 将其开源了一年多的 GraphQL 标记为 production ready ( http://graphql.org/blog/production-ready/ ), ...
- 处理用千牛导出淘宝数据,供Logstash到Elasticsearch使用。(NodeJS)
var rf=require("fs"); // 加载编码转换模块 //npm install iconv-lite var iconv = require('iconv-lite ...
- 读“40 分,60 分,90 分”
原文链接: http://mp.weixin.qq.com/s?__biz=MzA5MjYyNzY1OQ==&mid=2650901947&idx=1&sn=89af64d3b ...