Problem H
Glasses Foggy, Mom's Spaghetti
Conway’s glasses are foggy,
Knees weak, arms are heavy.
Palms are sweaty, mom’s spaghetti.
He’s nervous, but on the surface he looks calm and ready
to go home neat and tidy, but the streets are trippy.
In order to go home, Conway needs to follow the street sign that is straight in front of him (not to the left/right). Trying to see the sign, he raises his head by an angle, aligning the center of the lenses to the center of the road sign, where the lens is always perpendicular to the line of sight. Unfortunately, Conway’s glasses are foggy so he needs to wipe his lenses with his trusty microfiber cloth. Conway can only see through the clear areas on the lens, and thus he wants to know the height of his glasses lens so he knows how much he needs to wipe.
Given the following information, find the height of the smallest area he needs to wipe before he can see the entire sign (the minimum length of the green line segment).
-
Distance from the pupil to the lenses: $d$ units.
-
Horizontal distance from the pupil to the road sign: $x$ units.
-
Vertical distance from the pupil to the center of the road sign: $y$ units.
-
Vertical size of the road sign: $h$ units.
Input
The input consists of four space separated integers: $d$, $x$, $y$, $h$. It’s guaranteed that $0 < d < x < 10\, 000$, $0 \leq y < 10\, 000$, and $0 < h < 10\, 000$.
Output
Output one number, the minimum required height of the clear area on the lens. Your answer will be considered correct if the absolute or relative error does not exceed $10^{-6}$.
Sample Input 1 | Sample Output 1 |
---|---|
5 40 30 10 |
0.802890 |
Sample Input 2 | Sample Output 2 |
---|---|
1 100 0 20 |
0.200000 |