Time Limit: Java: 2000 ms / Others: 2000 ms

Memory Limit: Java: 65536 KB / Others: 65536 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 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.

提交代码