CYLINDER - Cylinder
Using a sheet of paper and scissors, you can cut out two faces to form a cylinder in the following way:
- Cut the paper horizontally (parallel to the shorter side) to get two rectangular parts.
- From the first part, cut out a circle of maximum radius. The circle will form the bottom of the cylinder.
- Roll the second part up in such a way that it has a perimeter of equal length with the circle's circumference, and attach one end of the roll to the circle. Note that the roll may have some overlapping parts in order to get the required length of the perimeter.
Given the dimensions of the sheet of paper, can you calculate the biggest possible volume of a cylinder which can be constructed using the procedure described above?
Input Specification
The input consists of several test cases. Each test case consists of two numbers w and h (1 ≤ w ≤ h ≤ 100), which indicate the width and height of the sheet of paper.
The last test case is followed by a line containing two zeros.
Output Specification
For each test case, print one line with the biggest possible volume of the cylinder. Round this number to 3 places after the decimal point.
Sample Input
10 10 10 50 10 30 0 0
Sample Output
54.247 785.398 412.095
In the first case, the optimal cylinder has a radius of about 1.591549, in the second case, the optimal cylinder has a radius of 5, and in the third case, the optimal cylinder has a radius of about 3.621795.
hide comments
Shubham.IIITM:
2012-06-21 07:29:13
value of pi caused me 3 wa!! |
|
time limit exceeded:
2012-04-06 15:13:04
nice one.... |
|
Ankit Paharia:
2011-12-06 17:18:43
plzz help me.....
|
|
robert:
2010-05-31 09:46:55
Yeah its right. |
|
Adrian Kuegel:
2010-02-24 15:15:17
Yes, I am quite sure that this value is correct. Note: the radius of the circle cannot be bigger than w/2. Last edit: 2010-02-24 15:20:39 |
|
Abhishek Ghosh:
2010-02-16 06:32:23
Is the max volume for w = 10 and h = 50 really 785.398 ? I am getting a value of 1144.709 and the formula is not violating any constraint. |
|
[Trichromatic] XilinX:
2009-03-09 04:43:49
I don't think so. |
|
JaceTheMindSculptor:
2009-03-08 19:20:50
does this problem require calculus? |
Added by: | Adrian Kuegel |
Date: | 2007-07-06 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ERL JS-RHINO NODEJS PERL6 VB.NET |
Resource: | own problem, used in University of Ulm Local Contest 2007 |