All submissions for this problem are available.
Siddhant and Divij play the Candy game. Initially Siddhant has N candies and Divij has M candies. In each turn, they toss an unbiased coin. Divij gives a candy to Siddhant if head comes up and takes one from him if tails comes up. Find the no. of turns the game is expected to last.
InputThe first line of input contains an integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case contains two integers N and M.
OutputPrint the expected number of turns rounded to exactly six decimal places.
Input: 2 1 1 1 2
Output: 1.000000 2.000000
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions