arrange m balls in to n baskets

44 Views Asked by At

How can I write a given natural number into sum of required (m) natural numbers? Example: 10=2+8+0 here m=3 Let n_i be the values i:e 2,8,0 in the above example. I want to know whether any method exists for finding ∏_i^m▒n_i ! = minimum for a given (m) & natural number.

1

There are 1 best solutions below

0
On

Let us assume that each basket has different name. The problem of $n$ baskets and $m$ balls can be transformed into a problem of permutating a string consisting of $n+1$ 1 and $m$ 0 where the head and tail of must be 1.

For example,

head--->1 0 0 0 0 0 0 ... 1 1 1 1 1 1 1 ... 1 0 1 0 1 0 ... 1<---tail

So actually we need to permutate $n-1$ 1 and $m$ 0.

Thus the answer is $\frac{(n-1+m)!}{(n-1)! m!}$