#P17151. [ICPC 2017 Xi'an R] God of Gamblers

    ID: 16757 Type: RemoteJudge 1000ms 512MiB Tried: 0 Accepted: 0 Difficulty: 6 Uploaded By: Tags>数学博弈论2017概率论ICPC鞅的停时定理西安

[ICPC 2017 Xi'an R] God of Gamblers

题目描述

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 kk RMB to the old man and throw the dice. If the point is 11, 22 or 33, he will win 2k2k 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 11 RMB first. If I lose, I will bet on 22 RMB. If I still lose, I will bet on 4,8,16,…4, 8, 16, \dots, and so on, until I win. And start to bet on 11 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 nn RMB, the old man has mm RMB, they stop until one of them lose all his money, what’s the probability of my father’s victory.

输入格式

The input contains multiple test cases. (No more than 2020)

In each test case:

The only line contains two numbers nn, mm. (0≤n,m≤20000000 \le n,m \le 2000000), indicate my father’s money and the old man’s. We guarantee max⁡(n,m)≥1\max(n,m) \ge 1.

输出格式

For each test case, print the answer in five decimal.

1 0
3 3
1.00000
0.50000