#P17151. [ICPC 2017 Xi'an R] God of Gamblers
[ICPC 2017 Xi'an R] God of Gamblers
Problem Description
When I was young, my father is a senior gaming enthusiast. One day, we saw a old man in the street. He had a dice and played with other people.
Every turn the gambler gives RMB to the old man and throw the dice. If the point is , or , he will win RMB back, otherwise he will get nothing.
My father told me, “I can win all his money by the following strategy”.
“Each turn, I bet on RMB first. If I lose, I will bet on RMB. If I still lose, I will bet on , and so on, until I win. And start to bet on RMB, do the same thing again.”
“If I don't have enough money to bet, I will bet on all my money.”
Now the question is, if the dice is even, my father has RMB, the old man has RMB, they stop until one of them lose all his money, what’s the probability of my father’s victory.
Input Format
The input contains multiple test cases. (No more than )
In each test case:
The only line contains two numbers , . (), indicate my father’s money and the old man’s. We guarantee .
Output Format
For each test case, print the answer in five decimal.
1 0
3 3
1.00000
0.50000