Sunday, September 29, 2013

15567. Playing With Balls

IITKWPCN

   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 upto 6 decimal digits.

CODE

 

t=input()
for i in range(t):
    s=raw_input()
    str=s.split(' ')
    w=int(str[0])
    b=int(str[1])
    c=b%10
    if(b%2==0):
        print("0.000000")
    else:
        print("1.000000")
 


 



No comments:

Post a Comment