Ceiling shower P26757


Statement
 

pdf   zip

html

Professor Oak is reforming his flat. He asks for a ceiling shower (consider it a point) in the middle of a 140 × 90 rectangular space. The start of the water pipe (a straigh line) must be located at a corner of the rectangle. Instead of using the Pythagoras’ theorem and cutting a pipe of length √702 + 452 ≃ 83.22, the plumber arbitrarily decides to cut a pipe of length 75. Therefore, the shower cannot be placed in the middle of the rectangle, so the goal is to minimize the uglyness of the shower, defined as the Manhattan distance between the shower and the center of the rectangle.

The picture to the right corresponds to the example above. The black line is the ideal pipe of length 83.21…, from (0, 0) to (70, 45). The red line shows the optimal placement with a pipe of length 75, which goes from (0, 0) to (60, 45), with an uglyness of | 60 − 70 | + | 45 − 45 | = 10 + 0 = 10.
  












(14,9) unit=0.5

[fillcolor=yellow,fillstyle=solid](0,0)(14,0)(14,9)(0,9)

linewidth=2

linecolor=black (0,0)(7,4.5)

linecolor=red (0,0)(6,4.5)

Can you help Prof. Oak to minimize the uglyness? He is so desperate with the reform of his flat that he does not even require the shower to be inside the rectangle.

Input

Input consists of several cases, each one with three strictly positive real numbers h, v and ℓ, corresponding to the dimensions h × v of the rectangle and the length ℓ of the pipe.

Output

For each case, print the minimum possible uglyness with four digits after the decimal point. To do so, include these two lines at the beginning of your main:

    cout.setf(ios::fixed);
    cout.precision(4);

The input cases do not have precision issues.

Public test cases
  • Input

    140 90 75
    140 90 83.21
    60 80 40
    60 80 50
    60 80 60
    2.718 3.142 23.42
    0.8 0.7 0.9
    

    Output

    10.0000
    0.0078
    13.4315
    0.0000
    11.9615
    21.8095
    0.4292
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    C++
    User solutions
    C++