N different balls will be put in the same bag of m How many kinds of programs?

N different balls will be put in the same bag of m How many kinds of programs?

 

9 to 10 ^ 7 + modulo.

 

n,m<=1000。

 

### how to recursive it?

 

With F [i] [j] denotes the i-th ball into different bags j identical, the number of programs and to ensure that each bag has the ball.

Consider the i-th ball is not a separate amp.

 

F [I] [J] = F [I- . 1 ] [J- . 1 ] + F [I- . 1 ] [J] J *. // a single place, put together to take because there j j bags

 

The answer is f [n] [0] + f [n] [1] + ... + f [n] [m].

 

The time complexity of O (nm)

Guess you like

Origin www.cnblogs.com/Adventurer-H/p/11241893.html