Example 2.2.6 There are keys numbered $1,2, \cdots, 10$ and boxes numbered $1,2, \cdots, 10$. Each key can only open the box with the same number. Now all the keys are placed into these boxes, one key per box, and then locked. How many different ways are there, at least, such that at least two boxes need to be opened to open all the boxes? If exactly two boxes need to be opened to open all the boxes, how many ways are there?
Let $\{1,2, \cdots, 10\}=A$, and let the key number in the $i$-th box be $f(i)$. Then $f$ is a one-to-one correspondence from $A \rightarrow A$, and the corresponding directed graph $\dot{G}(f, A)$ must be the union of several disjoint cycles. To open at least two boxes, the number of cycles must be at least two. The number of all mappings minus the number of single-cycle mappings is $10!-9!=9 \cdot 9!$.

The number of ways to open exactly two boxes corresponds to the case where $G(f, A)$ is exactly a double cycle. The lengths of the two cycles can be $(1,9),(2,8),(3,7),(4,6),(5,5)$, five types;

Thus, there are $\mathrm{C}_{10}^{1} \cdot 8!+\mathrm{C}_{10}^{2} \cdot 7!+\mathrm{C}_{10}^{3} \cdot 2$ ! $\cdot 6!+\mathrm{C}_{10}^{4} \cdot 3$ ! $\cdot 5$ ! + $\frac{1}{2} C_{10}^{5} \cdot 4!\cdot 4!$ ways.