Expanding Rods

Time limit1sMemory limit128 MB

Summary
Given a heated rod fixed at both ends, compute how far its midpoint bows out, using the circular-segment geometry and binary search.
Level

Medium6 of 10

Topics
Binary search, Geometry, Math
Solved
No attempts yet

Problem

When a thin rod of length LL is heated by nn degrees, it expands to a new length L′=(1+n⋅C)⋅LL' = (1 + n \cdot C) \cdot L, where CC is the coefficient of thermal expansion.

When such a rod is fixed between two solid walls and then heated, it expands and bows into the shape of a circular segment, with the original straight rod becoming the chord of that segment.

Your task is to compute the distance by which the center of the rod is displaced.

Input

The input consists of several lines. Each line contains three non-negative numbers: the initial length of the rod in millimeters, the temperature change in degrees, and the coefficient of thermal expansion of the material. It is guaranteed that no rod expands by more than one half of its original length. The last line contains three negative numbers and must not be processed.

Output

For each line of input, print a single line containing the displacement of the center of the rod in millimeters, rounded to 3 decimal places.

Examples4

  1. Example 1

    Input
    1000 100 0.0001
    15000 10 0.00006
    10 0 0.001
    -1 -1 -1
    
    Expected output
    61.329
    225.020
    0.000
    
  2. Example 2

    Input
    1000 5000 0.0001
    -1 -1 -1
    
    Expected output
    463.832
    
  3. Example 3

    Input
    10 100 0.001
    -1 -1 -1
    
    Expected output
    1.965
    
  4. Example 4

    Input
    200 20 0.0005
    7500 8 0.00012
    3 300 0.001
    -1 -1 -1
    
    Expected output
    12.266
    142.323
    1.050