Kevin In Spacey


Submit solution

Points: 1
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
C, C++, Java, Python, Rust

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, p and q (0 < p, q \leq 1000), describing a probability as the fraction \frac{p}{q}.

The lines are, in order:

  1. P(\text{Success}) - Kevin grabs the material.
  2. P(\text{Nothing}) - nothing happens, and Kevin may try again.
  3. P(\text{Failure}) - Kevin is ejected from Spacey.

It is guaranteed that each probability satisfies 0 < \frac{p}{q} < 1, and that P(\text{Success}) + P(\text{Nothing}) + P(\text{Failure}) = 1 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

There are no comments at the moment.