168. a) Find all positive, distinct integers \(x, y\) that satisfy the equation

\[
x^{y}=y^{x}
\]

b) Find all positive, distinct rational numbers \(x, y\) that satisfy the equation

\[
x^{y} \doteq y^{x}
\]

'(provide a formula that gives all solutions).
168. a) From the equality $x^{y}=y^{x}$, it is clear that the prime divisors of the numbers $x$ and $y$ are the same:

$$
x=p_{1}^{\alpha_{1}} p_{2}^{\alpha_{2}} \ldots p_{n}^{\alpha_{n}}, y=p_{1}^{\beta_{1}} p_{2}^{R_{2}} \ldots p_{n}^{\beta_{n}}
$$

where $p_{1}, p_{2}, \ldots, p_{n}$ are prime numbers. Then, due to our equality,

$$
\alpha_{1} y=\beta_{1} x, \alpha_{2} y=\beta_{2} x, \ldots, \alpha_{n} y=\beta_{n} x
$$

Assume that $y>x$; then from the written equalities it follows that

$$
\alpha_{1} x < \beta_{1} x, \alpha_{2} x < \beta_{2} x, \ldots, \alpha_{n} x < \beta_{n} x
$$

If $y = kx$ and $y > x$, then $k > 1$, from which $x > 1$. But it is easy to see that $2^{2-1}=2$, and for $x > 2$ and $k > 2$, $x^{k-1} > k$. Indeed, for $k > 2, x \geqslant 2$,

$$
x^{k-1} \geqslant 2^{k-1} > k
$$

since already $2^{3-1} > 3$, and for $k=2, x > 2$,

$$
x^{k-1} = x > 2 = k
$$

Therefore, the only solution to our equation in positive integers is $x=2, k=2, y=k x=4$.

b) Let the ratio $\frac{y}{x}$ be denoted by $k$, then $y=k x$. Substituting this expression for $y$ into our equation, we get:

$$
x^{k x}=(k x)^{x}
$$

Taking the $x$-th root of both sides and then dividing by $x$,

$$
x^{k-1}=k
$$

from which

$$
x=k^{\frac{1}{k-1}}, y=k k^{\frac{1}{k-1}}=k^{\frac{k}{k-1}}
$$

Let the rational number $\frac{1}{k-1}$ be equal to the irreducible fraction $\frac{p}{q}$. Substituting this expression for $\frac{1}{k-1}$ into our formulas, we get:

$$
\begin{gathered}
k-1=\frac{q}{p}, k=1+\frac{q}{p}=\frac{p+q}{p}, \frac{k}{k-1}=\frac{p+q}{q} ; \\
x=\left(\frac{p+q}{p}\right)^{\frac{p}{q}}, y=\left(\frac{p+q}{p}\right)^{\frac{p+q}{q}} .
\end{gathered}
$$

Since $p$ and $q$ are coprime, for $x$ and $y$ to be rational numbers, it is necessary that the $q$-th roots of the integers $p$ and $p+q$ can be extracted. But since for $q \geqslant 2$ and $p=n^{q}$, the inequality

$$
n^{q}<p+q<(n+1)^{q}=n^{q}+q n^{q-1}+\frac{q(q-1)}{2} n^{q-2}+\ldots
$$

holds, this is only possible for $q=1$.

Thus, all positive rational numbers satisfying our equation are given by the formula

$$
x=\left(\frac{p+1}{p}\right)^{p}, y=\left(\frac{p+1}{p}\right)^{p+1}
$$

where $p$ is any integer (except 0 and -1).