Parabola Dancing X04239


Statement
 

pdf   zip

html

One of the most beautiful parks in Meashara contains a place that birds like very much. It is a nice tree, with two fountains to the left and to the right from it. Birds like to sit on the tree, and to fly into the stream of water from the fountains.

A bird is sitting on the tree, and wants to move to another spot on the tree, using as short path as possible. Calculate this shortest path.

Input

Input consists of several test cases (at most 20).

Each test case contains four numbers X1, Y1, X2, Y2. We have 100 ≤ X1, X2 ≤ 200, 0 ≤ Y1, Y2 ≤ 100. The left fountain produces a parabola-shaped stream, which goes through points (100,0), (50,100) and (0,0). Similarly, the right stream goes through (200,0), (250,100) and (300,0).

The input ends with 0 0 0 0.

Output

Output the length of the shortest path.

Public test cases
  • Input

    120 50 180 100
    0 0 0 0
    

    Output

    218.9
    
  • Information
    Author
    Eryk Kopczynski
    Language
    English
    Official solutions
    Unknown.
    User solutions
    C++