HDU 2289 Cup

Source: Internet
Author: User

Cup

Time limit:3000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 5597 Accepted Submission (s): 1787


Problem DescriptionThe Whu ACM Team have 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.

Inputthe input consists of several test cases. The first line of input contains an integer T, indicating the num of test cases.
Each test case was on a single line, and it consists of four floating point numbers:r, R, H, V, representing the bottom Ra Dius, 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 is separated by one whitespace.
5. There is no. empty line between, neighboring cases.

Outputfor each test case, output the height of hot water on a single line. Round it to six fractional digits.

Sample Input1100 100 100 3141562

Sample Output99.999024

Source the 4th Baidu Cup final

Recommendlcy | We have carefully selected several similar problems for you:2298 2899 2199 2141 1551 just think about doing it with two points, and the floating-point numbers are equal by subtracting less than a small number.
#include <queue>#include<math.h>#include<stdio.h>#include<string.h>#include<iostream>#include<algorithm>using namespacestd;#defineLL Long Long#defineN 123456789#defineM 1234Const DoublePI = ACOs (-1.0);Const DoubleEE = 1e-8;Doubler,r,h,v,v;DoubleCalcDoubleh) {    DoubleX=r+h/h* (RR); returnpi*h* (r*r+x*x+r*x)/3;}intMain () {intT;cin>>T;  while(t--) {scanf ("%LF%LF%LF%LF",&r,&r,&h,&W); DoubleLl=0, rr=H,mid;  while(ll<=RR) {Mid= (LL+RR)/2; V=Calc (mid); if(Fabs (V-V) <=ee) Break; Else if(v<V) ll=mid+ee; ElseRR=mid-ee; } printf ("%.6f\n", mid); }    return 0;}

HDU 2289 Cup

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.