Sonic And Game
Sonic, Kohli and Anonymous are playing a game. They have a transparent bag of R red balls, B blue balls and G green balls. In each turn a player removes a ball of his desired color. Sonic has no particular affinity for any color so he chooses any random ball of his choice. Kohli dislikes green color so he never chooses a green ball. Anonymous likes only green color so he picks only green ball. Sonic starts the game first and then followed by Kohli and then Anonymous. This continues in a cycle. Sonic can win the game only if the last ball picked is green. Kohli or Anonymous win the game if all the green balls have been removed. Find the probability of Sonic's winning the game. All events occur with equal probability. In case of ties Sonic will win. Judge used: Ignores FP rounding up to 10 ^ -6.
First line contains 'T' denoting the number of test cases.
'T' lines follow each containing 3 space separated integers R, B, G.
For each test case output the probability of Sonic's winning the game.
Use fixed and setprecision(15) in c++ (Use the equivalent in other languages).
- T = 5832
- 0<=R, B, G<=17
Input: 4 1 2 3 2 2 4 1 5 6 7 8 9 Output: 0.833333333333333 0.500000000000000 0.783950617283951 0.153519614007011
|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, rust, SCALA, swift, 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, kotlin, PERL6, TEXT, SCM chicken, CLOJ, COB, FS|
Fetching successful submissions