Kevin In Spacey
Kevin, in search of the perfect origami material, has found himself in a strange dimension called Spacey. The laws of Spacey are such that any movement has a probability of success, nothing happening, or failure - resulting in Kevin falling out of Spacey, never able to return. If nothing happens, Kevin will just keep on trying until he either succeeds or fails.
Kevin is now right in front of his material! Given the probability of successfully grabbing the material, the probability of nothing happening, and the probability of Kevin being ejected from Spacey, determine Kevin's chance of success!
Input
The input consists of three lines. Each line contains two integers, and
(
), describing a probability as the fraction
.
The lines are, in order:
- Kevin grabs the material.
- nothing happens, and Kevin may try again.
- Kevin is ejected from Spacey.
It is guaranteed that each probability satisfies , and that
exactly.
Output
The probability that Kevin is able to grab the material, accurate to four decimal places.
In C++, you can do this via cout << fixed << setprecision(4) << x << endl;.
In Python, try print(f"{x:.4f}").
Example
Input 1
1 2
1 3
1 6
Output 1
0.7500
Input 2
1 4
1 2
1 4
Output 2
0.5000
Comments