Cylinder
Time limit1sMemory limit128 MB
Given a w by h sheet, cut it into two pieces, make a circle base from one and roll the other into the side, and maximize the cylinder volume.
- Level
Medium6 of 10
- Topics
- Geometry, Math, Brute force
- Solved
- No attempts yet
Problem
With a sheet of paper and a pair of scissors, you can cut out two faces and assemble a cylinder as follows:
- Cut the paper crosswise (parallel to its shorter side) into two rectangular pieces.
- From the first piece, cut out a circle of the largest possible radius. This circle becomes the base of the cylinder.
- Roll the second piece so that its perimeter equals the circumference of the circle, then attach one end of the roll to the circle. The roll may overlap itself in order to reach the required perimeter length.
Given the dimensions of the sheet of paper, compute the largest possible volume of a cylinder that can be built with the procedure above.
Input
The input consists of several test cases. Each test case contains two numbers and (), the width and the height of the sheet of paper.
The last test case is followed by a line containing two zeros.
Output
For each test case, print a single line with the largest possible volume of the cylinder, rounded to three digits after the decimal point.