Distribution of different objects into different boxes We want to put n different objects into n different boxes. In how many ways can we do this if we want that exactly two boxes remain empty?
 A: You can combine two standard counting problems from the "twelvefold way" to solve this: choose the subset of $n-2$ non-empty boxes in $\binom n{n-2}$ ways, then choose a surjective map from your $n$ objects to the selected $n-2$ boxes in $(n-2)!\genfrac\{\}{0pt}{}n{(n-2)}$ ways (those are Stirling numbers of the second kind). As this is a rather simple case, the Stirling number can be expressed as 
$$
  \genfrac\{\}{0pt}{}n{(n-2)}=\binom n3+\frac12\binom n2\binom{n-2}2 =\frac{n(n-1)(n-2)(3n-5)}{24}
$$
since there either is a group of $3$ objects with the same image (the term $\binom n3$) or two disjoint groups of $2$ elements (the other term, where $\frac12$ compensates for the two orders in which the same pair can be chosen).
So the result can be given for $n\geq2$, after combining $\binom n{n-2}$ and $(n-2)!$, as
$$
  \frac{n!}2\genfrac\{\}{0pt}{}n{(n-2)}=\frac{n!n(n-1)(n-2)(3n-5)}{48}.
$$
Test values for $n=2,3,\ldots,8$ are $0,3,84,1500,23400,352800,5362560$.
A: *
*Select the $2$ of $n$ boxes you wish to remain empty.  $\binom{n}{2}$ arrangements.

*Put the remaining $n$ objects, at least $1$ object into each of the $n-2$ remaining boxes and in either:
*
*1 box will have $3$ objects. Giving $\,^{n-2}C_1 \,^{n}P_{3}$ permutations.
*2 boxes will have 2 objects, giving $\,^{n-2}C_2 \,^{n}P_{2,2}$ permutations

$$\,^{n}C_{2}\cdot \left(\,^{n-2}C_1 \,^{n}P_{3}+\,^{n-2}C_2 \,^{n}P_{2,2}\right) \\ = \frac{n!}{2(n-2)!}\left(\frac{(n-2)!}{1!(n-3)!}\frac{n!}{6}+\frac{(n-2)!}{2!(n-4)!}\frac{n!}{4}\right) \\ = \frac{n!^2(4n-13)}{48(n-4)!}
$$
[edit: distinct objects]
A: The number of ways to choose the two boxes that are to remain empty is a combination:
$$\binom{n}{2} = \frac{n(n-1)}{2}$$
As for the remaining boxes, there can either be $1$ box with $3$ objects and $n-3$ boxes with $1$ object each, or $2$ boxes with $2$ objects each and $n-4$ boxes with $1$ object each.

Case 1: One box has three objects.
The number of ways to choose this special box is $n-2$. The number of ways to choose the three objects that go in this one box is $$\binom{n}{3}$$. Then, the number of ways to permute the remaining $n-3$ objects in the $n-3$ boxes is simply $(n-3)!$. Thus, the total number of ways to place the objects in this case is $$\binom{n}{2} \cdot (n-2) \cdot \binom{n}{3} \cdot (n-3)!$$

Case 2: Two boxes have two objects.
The number of ways to choose the two special boxes is $$\binom{n-2}{2}$$ Once these boxes are chosen, the number of ways to choose the objects that go in the first of these is $$\binom{n}{2}$$ After choosing these, the number of ways to choose the objects that go in the second box with two things in it, since there are $n-2$ objects left to choose from, is $$\binom{n-2}{2}$$ Finally, the number of ways to permute the remaining $n-4$ objects in the remaining $n-4$ boxes is $(n-4)!$. This gives the number of placements in this case as $$ \binom{n-2}{2} \cdot \binom{n}{2} \cdot \binom{n-2}{2} \cdot (n-4)!$$

The final answer is the sum of the answers in cases 1 and 2, which is
$$\boxed{\binom{n}{2} \cdot (n-2) \cdot \binom{n}{3} \cdot (n-3)! + \binom{n-2}{2} \cdot \binom{n}{2} \cdot \binom{n-2}{2} \cdot (n-4)!}$$

Edit: I noticed that the final answer, as I wrote it, could be simplified quite nicely. First, we can expand the binomial coefficients and combine $n-2$ and $(n-3)!$:
$$\frac{n(n-1)}{2} \cdot (n-2)! \cdot \frac{n(n-1)(n-2)}{6} + \frac{(n-2)(n-3)}{2} \cdot \frac{n(n-1)}{2} \cdot \frac{(n-2)(n-3)}{2} \cdot (n-4)!$$
Then, we find that both terms have $n!$ in them:
$$\frac{n!}{2}\binom{n}{3} + \frac{n!}{4}\binom{n-2}{2}$$
$$\frac{n!}{4}\cdot\frac{n(n-2)(n-3)}{3} + \frac{n!}{4}\cdot\frac{(n-2)(n-3)}{2}$$
This ends up as the relatively concise expression
$$\frac{n!(n-2)(n-3)}{4}\left(\frac{n}{3}+\frac{1}{2}\right)$$
A: I have this problem for homework at the moment. Here is my try: That number corresponds to ${n \choose 2} $ times the number of surjective functions from $\{1,2,\dots n\}$ to $\{1,2,\dots, n-2\}$. Namely, we first choose boxes that will be empty and for other boxes $n-2$ of them we know that they will have "preimage" in the set of objects.
