Time Limit: 2 second(s) | Memory Limit: 32 MB |
Your friend Jim has challenged you to a game. He has a bag containing red and blue marbles. There will be an odd number of marbles in the bag, and you go first. On your turn, you reach into the bag and remove a random marble from the bag; each marble may be selected with equal probability. After your turn is over, Jim will reach into the bag and remove a blue marble; if there is no blue marble for Jim to remove, then he wins. If the final marble removed from the bag is blue (by you or Jim), you will win. Otherwise, Jim wins.
Given the number of red and blue marbles in the bag, determine the probability that you win the game.
Input starts with an integer T (≤ 10000), denoting the number of test cases.
Each case begins with two integers R and B denoting the number of red and blue marbles respectively. You can assume that 0 ≤ R, B ≤ 500 and R+B is odd.
For each case of input you have to print the case number and your winning probability. Errors less than 10^{-6} will be ignored.
Sample Input |
Output for Sample Input |
5 1 2 2 3 2 5 11 6 4 11 |
Case 1: 0.3333333333 Case 2: 0.13333333 Case 3: 0.2285714286 Case 4: 0 Case 5: 0.1218337218 |
Developed and Maintained by
JANE ALAM JAN |
Copyright © 2012
LightOJ, Jane Alam Jan |