Picking Balls
Time Limit: 1 Second Memory Limit: 32768 KB
Balls of N different colors are put inside a box. There are Mi balls of color i. What is the possibility of taking K balls out of the box and exactly Pj of them are of color j for each j = 1, 2, ..., N.Input
Input contains several cases, each of which occupies 3 lines. The first line contains two non-negative integers N and K. The next line has N positive integers M1, M2, .... Mn, followed by a line with N non-negative integers P1, P2, .... Pn. It is guaranteed that K = P1 + P2 + ... + Pn. You may also assume that the total number of balls in any of the cases does not exceed 50.
Subsequent test cases are separated with a single blank line. The input is terminated with two -1's. This case is not to be processed.
Output
One number on a single line for each case - the possibility. Round to 5 digits after the decimal point.
Sample Input
3 3 2 2 2 1 1 1 2 1 2 1 0 1 -1 -1
Sample Output
0.40000 0.33333Submit
Source: Zhejiang University Local Contest 2004