# Number of ways to put N items into K bins with at least 1 per bin? [duplicate]

Possible Duplicate:
Unique ways to keep N balls into K Boxes?

Number of ways to put N items into K bins with at least 1 per bin?

I know that normally you can do N + K + 1 choose K - 1 or something like that, but that allows for bins where nothing is placed inside. What about when there must be at least 1 item per bin?

-

## marked as duplicate by Cameron Buie, Gerry Myerson, Marvis, J. M., Zev ChonolesJul 12 '12 at 3:07

Are the items indistinguishable and the boxes distinguishable? Are they both indistinguishable? Both distinguishable? – Arturo Magidin Jul 10 '12 at 23:53
@ArturoMagidin: I'm not sure... 7 and 3 yield 4, so I think order does not matter on both counts (all indistinguishable) – MyNameIsKhan Jul 11 '12 at 0:56

I am assuming that the $N$ items are identical. Line up the $N$ items in a row, with a little gap between the items. Choose $K-1$ of the gaps to put separators into. Put all the items from the left end to the first separator into Bin $1$, everything from the first separator to the second into Bin $2$, and so on.

Every choice of where to put the separators gives you a distribution into bins, with at least one per bin. And every distribution into bins with at least one per bin tells you where to put the separators.

So there are $\binom{N-1}{K-1}$ ways to do the job.

-

It's actually $\binom {n+k-1}{k-1}$ for the first problem.

If you want to ensure that every bin has at least one element, then take $n-k$ items and put them in $k$ bins as in the first prpblem, then add one item to each bin.

-
So n-k+1 choose k+1 – MyNameIsKhan Jul 10 '12 at 21:43