Number of ways to distribute $n$ distinct elements into $K$ distinct containers such that each is non-empty

216 Views Asked by At

Suppose we have $n$ distinct objects to be distributed into $K\leq n$ distinct containers, and each container must have contain at least one object. How many ways are there to do this?

For the non-empty constraint, there are ${n}\choose{K}$ ways to select $K$ elements, and each gives $K!$ ways to distribute them so that each container has one element.

Next we need to distribute the remaining $n-K$ elements into the containers however we like. Each remaining element has $K$ possible placements giving $K^{n-K}$ total ways (?)

Finally, to account for the containers being distinct, we can multiple the result by the number of ways to order the $K$ clusters which is $K!$.

I believe the correct answer for this should be $n^{K-1}$ but combining my above work does not give this result. Am I possibly overcomplicating this or missing something? Any hints would be great!