12.51 $n$ is a positive integer, prime $p>3$, find $3(n+1)$ groups of positive integers $x, y, z$ that satisfy the equation $x y z = p^n(x+y+z)$ (these groups are not just different in the order of their elements).
（27th International Mathematical Olympiad Candidate Problem, 1986）
[Solution] Let the powers of the prime factor $p$ in $x, y, z$ be $\alpha, \beta, \gamma$, respectively, and $\alpha \geqslant \beta \geqslant \gamma$. Then from
$$
x y z=p^{\prime \prime}(x+y+z)
$$

dividing both sides by $p^{\gamma}$ gives
$$
x y z p^{-\gamma}=p^{n}\left(x p^{-\gamma}+y p^{-\gamma}+z p^{-\gamma}\right).
$$

Thus,
$$
z p^{-\gamma} \mid p^{n}\left(x p^{-\gamma}+y p^{-\gamma}+z p^{-\gamma}\right).
$$

Since $z p^{-\gamma}$ has no factor $p$, we have
$$
z p^{-\gamma} \mid x p^{-\gamma}+y p^{-\gamma}+z p^{-\gamma}.
$$

Therefore,
$$
z \mid x+y.
$$

Let $x+y=m z$, then from (1) we get
$$
x y=p^{n}(m+1).
$$
(1) Taking $m=1$, i.e., $x y=2 p^{\prime \prime}$.

This yields $n+1$ sets of solutions:
$$
\left\{\begin{array}{l}
x=2 p^{i}, \\
y=p^{n-i}, \\
z=2 p^{i}+p^{n-i}, \quad i=0,1,2, \cdots, n .
\end{array}\right.
$$
(2) Taking $m=2$, i.e.,
$$
x y=3 p^{n}.
$$

This yields another $n+1$ sets of solutions:
$$
\left\{\begin{array}{l}
x=3 p^{j}, \\
y=p^{n-j}, \\
z=\frac{1}{2}\left(3 p^{j}+p^{n-j}\right), \quad j=0,1,2, \cdots, n .
\end{array}\right.
$$

When $n$ is odd, the solutions from (1) and (2) are distinct.
When $n$ is even, for $i=\frac{n}{2}, j=\frac{n}{2}$, the first set of solutions is $x=2 p^{\frac{n}{2}}, y=p^{\frac{n}{2}}, z=3 p^{\frac{n}{2}}$, and the second set of solutions is $x=3 p^{\frac{n}{2}}, y=p^{\frac{n}{2}}, z=2 p^{\frac{n}{2}}$. Therefore, the first and second sets have one common solution $\left(2 p^{\frac{n}{2}}, p^{\frac{n}{2}}, 3 p^{\frac{n}{2}}\right)$, just with a different order of $x, y, z$.
Thus, (1) and (2) together yield $2 n+1$ distinct sets of solutions.
(3) Taking $m=p^{k}+p^{n-k}$ yields $n+1$ sets of solutions:
$$
\left\{\begin{array}{l}
x=p^{k}, \\
y=p^{n}+p^{n-k}+p^{2 n-2 k}, \\
z=p^{n-k}+1, \quad k=0,1,2, \cdots, n .
\end{array}\right.
$$

When $k=n$, it is the same as the solution in (1) for $i=0$, and the rest are distinct.
Thus, we actually get $n$ sets of solutions.
From (1), (2), and (3), we get a total of $3 n+1$ distinct sets of solutions.
(4) Taking $m=\frac{p^{n}+1}{2}$, let
$$
\left\{\begin{array}{l}
x=1 \\
y=\frac{1}{2} p^{n}\left(p^{n}+3\right) \\
z=p^{n}+2 .
\end{array}\right.
$$
(5) Taking $m=p$, let
$$
\left\{\begin{array}{l}
x=p \\
y=p^{n}+p^{n-1} \\
z=p^{n-1}+p^{n-2}+1 .
\end{array}\right.
$$

These two sets of solutions are distinct from the above $3 n+1$ sets of solutions.
Thus, we get a total of $3(n+1)$ sets of solutions.