407205: GYM102697 176 Catapult

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

176. Catapulttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output
This problem is worth 85 points.

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).

Input

The 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$$$.

Output

Output 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.

ExamplesInput
5 0 5 7
Output
7.0000000000000195
Input
5 0 9 7
Output
7.62222191701435
Input
5 6 1 12
Output
15.778572363190715
Note

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.

加入题单

上一题 下一题 算法标签: