【Example 7】Find the number of one-to-one mappings $f$ with the following properties: (i) $f$ maps the set $A=\{1,2,3,4,5\}$ onto itself; (ii) exactly 2 elements in $A$ are mapped to themselves.
Solution: Suppose there are 5 balls numbered $1 \sim 5$ and 5 boxes numbered 1～5. Place the 5 balls into the 5 boxes (one ball per box). Consider the ball numbers as the original images and the box numbers as the images. Then each way of placing the balls defines a one-to-one mapping from $A$ to itself. Among these, “exactly 2 elements have themselves as their images” is equivalent to exactly two “pairs” appearing. Thus, by the “matching problem,” we know there are
$$
\frac{5!}{2!}\left(\frac{1}{2!}-\frac{1}{3!}\right)=20
$$
different one-to-one mappings $f$ with the described property.