Example 6 Xiao Ming divides a cube with an edge length of 4 into 29 smaller cubes with integer edge lengths. Then the number of smaller cubes with an edge length of 1 is ( ).
(A) 22
(B) 23
(C) 24
(D) 25
Explanation 1: If a cube with an edge length of 3 is cut out, then there can only be 1 cube with an edge length of 3. The remaining ones are all cubes with an edge length of 1 (37 in total), which does not meet the requirements.

Let the number of cubes with an edge length of 2 be $x$, and the number of cubes with an edge length of 1 be $y$. Then
$$
\left\{\begin{array} { l } 
{ x + y = 2 9 , } \\
{ 8 x + y = 6 4 }
\end{array} \Rightarrow \left\{\begin{array}{l}
x=5, \\
y=24 .
\end{array}\right.\right.
$$

Therefore, the answer is (C).
Explanation 2: Let the number of cubes with edge lengths of $1, 2, 3$ be $x, y, z$ respectively. According to the problem, we have
$$
x+8 y+27 z=64 \text {. }
$$

Note that $x+y+z=29$.
If $z=0$, then $x+y=29$. Solving this equation together with equation (1), we get $x=5, y=24$.

If $z=1$, then $x+y=28$. Solving this equation together with equation (1) yields no integer solutions.
Therefore, the answer is (C).