407205: GYM102697 176 Catapult
Description
You're testing out a catapult that you built for POE class, and you're trying to get it to launch an eraser over a wall.
The catapult launches the eraser $$$a$$$ meters away from the wall, and you're trying to get the catapult to hit a target $$$b$$$ feet above the ground, and $$$c$$$ meters away from the wall in the exact opposite direction.
The wall is $$$d$$$ meters high, and it is very thin (assume it has no thickness).
Given this information, figure out the minimum possible maximum height of the eraser, such that the eraser still clears the wall. In other words, among all eraser trajectories that hit the target and successfully clear the wall, find the lowest possible maximum height of the eraser.
Assume that you launch the device in a vacuum (i.e. there is no air resistance).
InputThe only line of input contains 4 space-separated positive integers: $$$a$$$, $$$b$$$, $$$c$$$, and $$$d$$$, as described above. $$$b$$$ is guaranteed to be less than $$$d$$$.
OutputOutput a single positive integer $$$h$$$: the maximum height of the eraser, if you launch it so that it hits the target and clears the wall, and has the minimum possible maximum height.
ExamplesInput5 0 5 7Output
7.0000000000000195Input
5 0 9 7Output
7.62222191701435Input
5 6 1 12Output
15.778572363190715Note
You don't need to use any physics equations to solve this problem. You can solve it using only algebra.
Also, your answers don't have to be exactly equal to ours. As long as they're within a few decimal places, your solution will be judged as correct.