Going Shopping with Grandma (II)

After leaving the pharmacy with grandma, Eloi has realized there are still some interesting mathematical puzzles regarding granny’s pill taking routine. Granny’s memory pills come in two sizes: large and small. The dose in each large pill is equivalent to that in two small ones. Eloi observes granny picks a pill at random from the bottle every day: if it’s a small one, she takes it; otherwise she splits it and takes a half, replacing the other which is from then on considered a small pill. Eloi would like to solve the following puzzles regarding a given bottle with l large pills and s small pills:

  1. What is the expected number of small pills remaining when the last large pill is picked? 2. What is the expected day in which the last large pill is picked? Your task is to help Eloi solve those puzzles. Input The input consists of several test cases. Each test case consists of a line with two blank separated numbers l and s (0 ≤ l ≤ 100 and 0 ≤ s ≤ 100). The end of the input is given by l = s = 0, which should not be processed as a test case. Output For each test case, output a line with two blank-separated numbers a1 and a2: a1 is the answer to question 1 and a2 to question 2 above. Each ai must approximate the correct answer to within 10−6. Sample Input 21 65 100 2 19 78 00 Sample Output 1.833333333333 3.166666666667 3.164285714286 13.835714285714 5.207179497838 196.792820502162 7.447739657144 108.552260342856