Under construction

Still being built. Things may change

Moonshine

Time limit1sMemory limit128 MB

Summary
Given the upright fill depth of a coaxial body-neck-shoulder can, find the whiskey depth when the can lies on its side.
Level

Hard8 of 10

Topics
Geometry, Math, Binary search, Simulation
Solved
No attempts yet

Problem

Granny is preparing homemade moonshine whiskey for a large family reunion. Because the family is so big, she brews it in several batches and pours them all into one large metal cream can. After brewing — and sampling — a few batches, she stumbles and knocks the can onto its side. Fortunately the lid is sealed tight, so not a drop of whiskey is lost.

The can is a solid of revolution about a single central axis. It has a cylindrical body of height hbh_b and diameter dbd_b, and a cylindrical neck of height hnh_n and diameter dnd_n. The body and neck are coaxial and are joined by a tapered conic shoulder (a cone frustum), so that the can's total height is hh; the shoulder's height is therefore h−hb−hnh - h_b - h_n. The bottom of the can (a disk of diameter dbd_b) closes the body, and the lid (a disk of diameter dnd_n) closes the neck.

With the can standing upright, the whiskey reached a depth of kk cm. After the can is laid on its side, what is the depth of the whiskey, measured from the lowest point of the can?

Input

The input consists of several test cases. Each test case is a line containing six real numbers kk, hbh_b, dbd_b, hnh_n, dnd_n, hh. You may assume that 100≥h≥hb+hn100 \ge h \ge h_b + h_n and that 100≥db≥dn100 \ge d_b \ge d_n. A line containing 0 0 0 0 0 0 follows the last test case and must not be processed.

Output

For each test case, output a single line containing ss, the depth of the whiskey when the can is lying on its side, rounded to two decimal places.

Examples5

  1. Example 1

    Input
    5.625 10.0 10.0 5.0 5.0 15.0
    0 0 0 0 0 0
    
    Expected output
    5.00
    
  2. Example 2

    Input
    6.0 12.0 12.0 6.0 6.0 24.0
    0 0 0 0 0 0
    
    Expected output
    4.78
    
  3. Example 3

    Input
    20.0 12.0 12.0 6.0 6.0 24.0
    0 0 0 0 0 0
    
    Expected output
    10.45
    
  4. Example 4

    Input
    24.0 12.0 12.0 6.0 6.0 24.0
    0 0 0 0 0 0
    
    Expected output
    12.00
    
  5. Example 5

    Input
    10.0 12.0 8.0 8.0 8.0 20.0
    0 0 0 0 0 0
    
    Expected output
    4.00