5. Find all triples $(p, x, y)$ such that $x^{p-1}+y$ and $x+y^{p-1}$ are both powers of $p$, where $p$ is a prime, and $x, y$ are positive integers.
5. $(p, x, y)$
$$
\begin{aligned}
\in & \{(3,2,5),(3,5,2)\} \cup \\
& \left\{\left(2, n, 2^{i}-n\right) \mid 02\right\} \text{, suppose there exist positive integers } a \text{ and } b \text{ such that}
$$
$$
x^{p-1}+y=p^{a}, x+y^{p-1}=p^{b} \text{. }
$$

Assume without loss of generality that $x \leqslant y$.
From $p^{a}=x^{p-1}+y \leqslant x+y^{p-1}=p^{b}$
$\Rightarrow a \leqslant b \Rightarrow p^{a} \mid p^{b}$.
By $p^{b}=y^{p-1}+x=\left(p^{a}-x^{p-1}\right)^{p-1}+x$, and
$p-1$ is even, we know
$$
0 \equiv x^{(p-1)^{2}}+x\left(\bmod p^{a}\right) \text{. }
$$

If $p \mid x$, by $x^{(p-1)^{2}-1}+1$ is not divisible by $p$, we know $p^{a} \mid x$.
Thus, $x \geqslant p^{a}>x^{p-1} \geqslant x$, a contradiction.
Therefore, $p \nmid x$.
This indicates,
$$
p^{a}\left|\left[x^{(p-1)^{2}-1}+1\right] \Rightarrow p^{a}\right|\left[x^{p(p-2)}+1\right] \text{. }
$$

By Fermat's Little Theorem, we know
$$
x^{(p-1)^{2}} \equiv 1(\bmod p) \text{. }
$$

Thus, $p \mid(x+1)$.
Let $p^{r} \|(x+1)\left(r \in \mathbf{Z}_{+}\right)$.
By the binomial theorem,
$$
x^{p(p-2)}=\sum_{k=0}^{p(p-2)} \mathrm{C}_{p(p-2)}^{k}(-1)^{p(p-2)-k}(x+1)^{k} \text{. }
$$

Except for the terms corresponding to $k=0,1,2$, all other terms in the above sum are divisible by $p^{3}$ and also by $p^{r+2}$.
The term corresponding to $k=2$ is
$$
-\frac{p(p-2)\left(p^{2}-2 p-1\right)}{2}(x+1)^{2} \text{, }
$$

which is divisible by $p^{2 r+1}$ and also by $p^{r+2}$;
The term corresponding to $k=1$ is
$$
p(p-2)(x+1) \text{, }
$$

which is divisible by $p^{r+1}$ but not by $p^{r+2}$;
The term corresponding to $k=0$ is -1.
This indicates, $p^{r+1} \|\left[x^{p(p-2)}+1\right]$.
On the other hand, since $p^{a} \mid\left[x^{p(p-2)}+1\right]$, then $a \leqslant r+1$.
By $p^{r} \leqslant x+1 \leqslant x^{p-1}+y=p^{a} \Rightarrow r \leqslant a$.
Thus, $a=r$ or $a=r+1$.
If $a=r$, then $x=y=1$, which contradicts $p>2$.
Therefore, $a=r+1$.
Since $p^{r} \leqslant x+1$, we have
$$
x=\frac{x^{2}+x}{x+1} \leqslant \frac{x^{p-1}+y}{x+1}=\frac{p^{a}}{x+1} \leqslant \frac{p^{a}}{p^{r}}=p \text{. }
$$

Since $p \nmid (x+1)$, then $x+1=p$.
At this point, $r=1, a=2$.
If $p \geqslant 5$, then
$$
\begin{array}{l}
p^{a}=x^{p-1}+y>(p-1)^{4}=\left(p^{2}-2 p+1\right)^{2} \\
>(3 p)^{2}>p^{2}=p^{a},
\end{array}
$$

a contradiction.
Thus, $p=3, x=2, y=p^{a}-x^{p-1}=5$.