N47 (40-4, Taiwan, China) Determine all pairs of positive integers $(n, p)$, such that: $p$ is a prime number, $n \leqslant 2 p$, and $(p-1)^{n}+1$ is divisible by $n^{p-1}$.
Obviously, $(n, p)=(1, p),(2,2)$ satisfy the problem.
For $n \geqslant 2, p \geqslant 3$, since $(p-1)^{n}+1$ is odd, $n$ is also odd, hence $n < 2 p$.
Let $q$ be the smallest prime divisor of $n$, then

Therefore,
$$
\begin{array}{c}
q \mid(p-1)^{n}+1, \\
(p-1)^{n} \equiv-1 \quad(\bmod q),
\end{array}
$$

and $(q, p-1)=1$. By the choice of $q$, we have $(n, q-1)=1$, so by Bézout's theorem, there exist integers $u, v$, such that
$$
u n+v(q-1)=1
$$

According to Fermat's little theorem, we have
$$
\begin{aligned}
p-1 & =(p-1)^{n u+v(q-1)} \\
& =(p-1)^{n u} \cdot(p-1)^{v(q-1)} \\
& \equiv(-1)^{u} \cdot 1^{v} \\
& =(-1)^{u} \quad(\bmod q) .
\end{aligned}
$$

Since $u n=1-v(q-1)$ is odd, $u$ is odd, so $p-1 \equiv-1 \quad(\bmod q)$, hence $q \mid p$, thus $q=p$. Since $p \mid n, n<2 p$, we have $n=p$, so we get
$$
\begin{array}{l} 
p^{p-1} \mid(p-1)^{p}+1 \\
(p-1)^{p}+1= p^{p}-\mathrm{C}_{p}^{1} p^{p-1}+\mathrm{C}_{p}^{2} p^{p-2}-\cdots+\mathrm{C}_{p}^{p-1} p-1+1 \\
= p^{2}\left(p^{p-2}-\mathrm{C}_{p}^{1} p^{p-3}+\mathrm{C}_{p}^{2} p^{p-4}-\cdots-\mathrm{C}_{p}^{p-2}+1\right) .
\end{array}
$$

In the above expression, $p^{p-2}-\mathrm{C}_{p}^{1} p^{p-3}+\cdots-\mathrm{C}_{p}^{p-2}+1$ is divisible by $p$ except for 1, so $p-1 \leqslant 2, p=3$.
In summary, all solutions are $(2,2),(3,3)$ and $(1, p)$, where $p$ is any prime number.