High School Programming League 2008/2009

Bridge Building

Problem code: HS09BRI

Find a place to build a bridge over the river, so as to minimize the length of the shortest route between two cities A and B, located on opposite sides of the river.

Figure

Input

There is exactly one line of input, containing four integers a, b, c, and h (10 ≤ a, b, c, h < 1000000), separated by spaces. a - the distance from city A to the river (the length of segment AE in the figure), b - the distance from city B to the river (the length of segment BG in the figure), c - the distance between A and B along the axis parallel to the river (the length of segment BF in the figure) and h - the width of the river (CD in the figure).

Output

Your program should write a single number to the standard output, equal to the length of the shortest path between A and B using the bridge, accurate up to two digits after the decimal dot.

Example

Input:
10 12 90 10
Output:
102.65  

Scoring

For solving this problem you will score 10 points.


Added by:Adam Dzedzej
Date:2009-09-20
Time limit:1s
Source limit:50000B
Languages:SED C99 strict C++ 4.0.0-8 C++ 4.3.2 TCL SCALA NEM PHP SCM guile LISP sbcl LISP clisp ERL TECS TEXT DOC PDF PS PERL 6 JS
Resource:High School Programming League (thanks to Talent Association)
SPOJ System © 2010 Sphere Research Labs. All Rights Reserved.