Example 8. There is a rectangular prism with length, width, and height of $m, n, r(m \leqslant n \leqslant r)$, respectively. After its surface is painted red, it is cut into cubes with an edge length of 1. It is known that the sum of the number of cubes without any red faces and the number of cubes with two red faces, minus the number of cubes with one red face, equals 1985. Find the values of $m, n, r$. (1985, National Junior High School League)
According to the problem, the number of unit cubes without red faces is $(m-2)(n-2)(r-2)$, the number of unit cubes with one red face is $2[(m-2)(n-2)+(m-2)(r-2)+(n-2)(r-2)]$, and the number of unit cubes with two red faces is $4[(m-2)+(n-2)+(r-2)]$. Setting up the equation, we get
$$
\begin{array}{l}
\quad(m-2)(n-2)(r-2)+4[(m-2)+(n-2) \\
+(r-2)]-2[(m-2)(n-2)+(m-2)(r-2) \\
+(n-2)(r-2)]=1985 .
\end{array}
$$

Simplifying and organizing, we get $(m-4)(n-4)(r-4)=1977$.
Since $1977=3 \times 659$,
we have $(m-4)(n-4)(r-4)=1 \times 3 \times 659$.
Given $m-4 \leqslant n-4 \leqslant r-4$, we get
$$
m-4=1, n-4=3, r-4=659 .
$$

Thus, $m=5, n=7, r=663$.
Also, from $(m-4)(n-4)(r-4)=1 \times 1 \times 1977$,
we get another solution $m=5, n=3, r=1981$.
Furthermore, from $(m-4)(n-4)(r-4)=(-1) \times(-1) \times 1977$, we get $m=3, n=3, r=1981$.
When $m=2$, the original equation becomes
$$
0+4[(n-2)+(r-2)]-2(n-2)(r-2)=1985 \text {. }
$$

The left side is even, while the right side is odd, so the equation has no solution.
When $m=1$, the original equation becomes $0+(n-2)(r-2)-0=1985$.
It is easy to see that when $n, r \geq 3$, from $1985=1 \times 1985$ or $1985=5 \times 397$, we get two more solutions: $n-2=1, r-2=1985$, hence $n=3, r=1987$ or $n-2=5, r-2=397$. Thus, $n=7, r=399$.
In summary, the solutions for $m, n, r$ are 5 groups:
(1) $\left\{\begin{array}{l}m=5, \\ n=7, \\ r=663 ;\end{array}\right.$ (2) $\left\{\begin{array}{l}m=5 ; \\ n=5, \\ r=1981 ;\end{array} \quad\right.$ (3) $\left\{\begin{array}{l}m=3, \\ n=3, \\ r=1981 ;\end{array}\right.$
(4) $\left\{\begin{array}{l}m=1, \\ n=3, \\ r=1987 ;\end{array} \quad\right.$ (5) $\left\{\begin{array}{l}m=1 \\ n=7 \\ r=399 .\end{array}\right.$