Submit | All submissions | Best solutions | Back to list |
IITKWPCN - Playing With Balls |
There are W white balls and B black balls in a bag. A magician is performing tricks by drawing balls from the bag.
In each step, the magician randomly removes any two balls from the bag. If the drawn balls are of the same color, he will put one white ball in the bag, otherwise he will put a black ball in it. The two drawn balls from the bag from the ball are discarded.
He keeps on doing the above tricks until there is only one ball remaining in the bag.
Given W and B, you have to determine the probability that the color of last ball remaining in the bag is black. You should print the answer with accuracy of up to 6 decimal digits.
Input
T : number of test cases (1 ≤ T ≤ 104)
For every test case W and B are given (0 ≤ W ≤ 108 and 0 ≤ B ≤ 108 and W + B ≠ 0)
Output
For each test case, output the probability as stated in the problem statement.
Example
Input: 2 1 1 1 2 Output: 1.000000 0.000000
Added by: | praveen123 |
Date: | 2013-08-06 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | IITK ACA CSE online judge |
hide comments
|
||||||
2014-01-05 21:57:12 Vipul Pandey
easy if you get it. Otherwise a good problem of probability. |
||||||
2014-01-04 15:03:13 tbos
AC in a Go :):D \o/ Last edit: 2014-01-04 15:19:47 |
||||||
2014-01-04 14:04:40 ritz
nice problem statement :) (Y) |
||||||
2014-01-02 20:51:00 ABHISHEK004
simple.... similar to HAPPY COINS.... :) |
||||||
2013-12-30 06:58:54 RG
Yeah its really too simple... No need for programming Simple probability.. :) |
||||||
2013-12-24 12:38:35 Ankit Kumar
Hint : It's just TOO simple ;) and a beautiful question too!!! Last edit: 2013-12-24 12:38:57 |
||||||
2013-12-23 19:48:03 Anubhav Balodhi
Good Q on Probability theory... |
||||||
2013-08-24 12:38:24 Raman Shukla
Nice one... My 150th Classical on spoj... |