Beavergnaw
Time limit1sMemory limit128 MB
Given a cylinder of diameter D and height D, find the inner cylinder diameter d so that the remaining wood (two frustums plus a middle cylinder) has the requested volume. Output d to three decimals for each test case.
- Level
Medium7 of 10
- Topics
- Geometry, Math, Binary search
- Solved
- No attempts yet
Problem
When a beaver gnaws a tree, it cuts a very specific shape out of the trunk. What is left of the trunk looks like two frustums of a cone joined by a cylinder whose diameter equals its height. A very curious beaver, trying not to topple the tree, wants to work out what the diameter of that joining cylinder should be so that he gnaws out a given amount of wood. Help him with the calculation.
Consider an idealized beaver gnawing an idealized tree. Assume the trunk is a cylinder of diameter , and that the beaver works on a segment of the trunk whose height is also . What should the diameter of the inner cylinder be so that the beaver gnaws out exactly cubic units of wood?
Input
The input contains several test cases, one per line. Each line has two integers and separated by whitespace, where is given in linear units and in cubic units. never exceeds the maximum volume of wood the beaver can gnaw out. The line with and marks the end of the input and must not be processed.
Output
For each test case, print one line containing the value of , measured in linear units, rounded to exactly three digits after the decimal point.