Odds On
Tom and Ray are facing off in an epic game of chance!
The game is played with a running "score" and a special coin that has a positive integer printed on each side. Tom and Ray take turns flipping the coin. After each flip, the number that lands face-up is added to the score.
Ray wins if the score ever becomes exactly at any point during the game. Tom wins if the score passes
.
What is the probability that Ray will win the game?
Input
The first line contains two integers and
, the numbers on each side of the coin.
The second line contains an integer
, the score Ray must reach to win.
Output
Output the probability that Ray will win the game, correct to decimal places.
Examples
Input 1
1 2
2
Output 1
0.7500
Ray can win in ways:
- If a
is flipped on the first turn (
probability).
- If a
is flipped on the first turn, and again on the second (
probability).
Therefore, he has a probability of winning.
Input 2
2 3
5
Output 2
0.5000
Ray can win in ways:
- If a
is flipped on the first turn, and a
is flipped on the second (
probability).
- If a
is flipped on the first turn, and a
is flipped on the second (
probability).
Therefore, he has a probability of winning.
Input 3
10 10
5
Output 3
0.0000
There is no way for Ray to win.
Comments