Alice, Bob and the Leaky Ball Bag
Alice and Bob found an old cloth bag with p pink balls and g grey balls inside, and agreed that
whoever pulls out a pink ball first wins. There is a catch: the bag has a hole, and Bob draws so
clumsily that every time he pulls out a grey ball, the bag jerks and another ball slips out through
the hole and rolls away under the sofa.
Formally, the players take turns, Alice first. On each turn:
- If the bag is empty, the game ends and Bob wins.
- Otherwise the current player draws one ball, chosen uniformly at random among the balls in the bag, and it does not go back.
- If the drawn ball is pink, the current player wins and the game ends.
- If it is grey and the current player is Bob, then, if the bag is not empty, one more ball chosen uniformly at random among the remaining balls falls out of the bag and is lost. A ball that falls out does not count as anyone's draw, whatever its colour.
- The turn passes to the other player.
A grey draw by Alice makes nothing fall out. Find the probability that Alice wins.
Input
A single line with two integers p and g (0 ≤ p, g ≤ 1000): the numbers of pink and grey balls.
Output
Print the probability that Alice wins. Your answer is accepted if its absolute or relative error is at most 10^-9.
Notes
In the first example Alice wins at once with probability 1/4. Otherwise she drew grey and Bob faces one pink and two grey balls: he wins with probability 1/3, and with probability 2/3 he draws grey, after which one of the last two balls falls out. If the pink one falls out, the bag holds only a grey ball and Alice cannot win; if the grey one falls out, Alice draws the pink ball. In total Alice wins with probability 1/4 + 3/4 · 2/3 · 1/2 = 1/2.
If there are no pink balls at all, Alice can never win.