$12 \cdot 62$ There is a rectangular prism with length, width, and height as positive integers $m, n, r(m \leqslant n \leqslant r)$, respectively. After the surface is painted red, it is cut into unit cubes. It is known that the number of unit cubes with no red faces plus the number of unit cubes with two red faces, minus the number of unit cubes with one red face equals 1985. Find the values of $m, n, r$.
(China Junior High School Mathematics League, 1985)
［Solution］(1). Let $m>2$.
According to the problem, the number of cubes without red is
$$
k_{0}=(m-2)(n-2)(r-2) ;
$$

The number of cubes with one red face is
$$
k_{1}=2(m-2)(n-2)+2(m-2)(r-2)+2(n-2)(r-2) \text {; }
$$

The number of cubes with two red faces is
$$
k_{2}=4(m-2)+4(n-2)+4(r-2) .
$$

Thus, according to the problem, we have
$$
k_{0}+k_{2}-k_{1}=1985
$$

That is

That is
Given
$$
\begin{aligned}
& (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{aligned}
$$

After rearrangement, we get
$$
[(m-2)-2][(n-2)-2][(r-2)-2]=1985-8=1977 \text {, }
$$
$$
\begin{aligned}
(m-4)(n & -4)(r-4)=1977 \\
1977 & =1 \cdot 3 \cdot 659 \\
& =1 \cdot 1 \cdot 1977 \\
& =(-1) \cdot(-1) \cdot 1977
\end{aligned}
$$

Then we have
$$
\left\{\begin{array} { l } 
{ m - 4 = 1 , } \\
{ n - 4 = 3 , } \\
{ r - 4 = 6 5 9 , }
\end{array} \quad \left\{\begin{array} { l } 
{ m - 4 = 1 , } \\
{ n - 4 = 1 , } \\
{ r - 4 = 1 9 7 7 , }
\end{array} \quad \left\{\begin{array}{l}
m-4=-1 \\
n-4=-1 \\
r-4=1977
\end{array}\right.\right.\right.
$$

Therefore, we get
$$
\left\{\begin{array} { l } 
{ m = 5 , } \\
{ n = 7 , } \\
{ r = 6 6 3 , }
\end{array} \quad \left\{\begin{array} { l } 
{ m = 5 , } \\
{ n = 5 , } \\
{ r = 1 9 8 1 , }
\end{array} \quad \left\{\begin{array}{l}
m=3, \\
n=3, \\
r=1981
\end{array}\right.\right.\right.
$$
(2). Let $m=1$, when $n=1$ there is no solution, so $n \geqslant 2$.
According to the problem, the number of squares without red is $k_{0}=0$;
The number of squares with one red face is $k_{1}=0$;
The number of squares with two red faces is
$$
\begin{array}{l}
k_{2}=(n-2)(r-2) . \\
k_{0}+k_{2}-k_{1}=1985,
\end{array}
$$

Thus, we have
That is $(n-2)(r-2)=1985=5 \cdot 397=1 \cdot 1985$.
$$
\left\{\begin{array} { l } 
{ n - 2 = 5 , } \\
{ r - 2 = 3 9 7 , }
\end{array} \quad \left\{\begin{array}{l}
n-2=1 \\
r-2=1985
\end{array}\right.\right.
$$

Therefore, we get
$$
\left\{\begin{array} { l } 
{ m = 1 , } \\
{ n = 7 , } \\
{ r = 3 9 9 , }
\end{array} \quad \left\{\begin{array}{l}
m=1, \\
n=3, \\
r=1987 .
\end{array}\right.\right.
$$
(3). Now let $m=2$, then
$$
k_{0}=0 .
$$

Thus, we have
$$
k_{2}-k_{1}=1985 \text {. }
$$

Since both $k_{1}$ and $k_{2}$ are even numbers, the above equation cannot hold.
In summary, (1), (2), (3), there are five sets of $m, n, r$ that satisfy the problem:
$$
\begin{array}{lll}
m_{1}=5, & n_{1}=7, & r_{1}=663 ; \\
m_{2}=5, & n_{2}=5, & r_{2}=1981 ; \\
m_{3}=3, & n_{3}=3, & r_{3}=1981 ; \\
m_{4}=1, & n_{4}=7, & r_{4}=399 ; \\
m_{5}=1, & n_{5}=3, & r_{5}=1987
\end{array}
$$