This page is still under construction.

Parts of this page are still being built. What you see may change.

Beavergnaw

Time limit1sMemory limit128 MB

Summary
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 DD, and that the beaver works on a segment of the trunk whose height is also DD. What should the diameter dd of the inner cylinder be so that the beaver gnaws out exactly VV cubic units of wood?

Input

The input contains several test cases, one per line. Each line has two integers DD and VV separated by whitespace, where DD is given in linear units and VV in cubic units. VV never exceeds the maximum volume of wood the beaver can gnaw out. The line with D=0D = 0 and V=0V = 0 marks the end of the input and must not be processed.

Output

For each test case, print one line containing the value of dd, measured in linear units, rounded to exactly three digits after the decimal point.

Examples4

  1. Example 1

    Input
    10 250
    20 2500
    25 7000
    50 50000
    0 0
    
    Expected output
    8.054
    14.775
    13.115
    30.901
    
  2. Example 2

    Input
    1 0
    0 0
    
    Expected output
    1.000
    
  3. Example 3

    Input
    10 0
    0 0
    
    Expected output
    10.000
    
  4. Example 4

    Input
    5 10
    7 20
    3 1
    0 0
    
    Expected output
    4.731
    6.730
    2.928