Submit | All submissions | Best solutions | Back to list |
HS09BRI - Bridge Building |
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.
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: | 0.200s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: CLOJURE ERL JS-RHINO NODEJS OBJC PERL6 SCALA SQLITE TCL VB.NET |
Resource: | High School Programming League (thanks to Talent Association) |