5. Let $m, n$ be coprime positive integers. Initially, the numbers $\frac{m}{n}, \frac{n}{m}$ are written on the blackboard. Next, the following operation is repeatedly performed: choose any two existing numbers $x, y$, and then write $\frac{x+y}{2}$ or $\frac{2xy}{x+y}$ on the blackboard. Find all values of $m, n$ such that after a finite number of operations, the number 1 can appear on the blackboard.
5. First, prove: If $m+n$ has an odd prime factor $p$, then $m, n$ definitely do not meet the requirements. This can be directly derived from the following proposition.

Proposition Let $p$ be an odd prime, for coprime positive integers $u, v, \frac{u}{v} \equiv -1 \pmod{p}$ means $p \nmid v$ and $p \mid (u+v)$. If the two initial numbers on the blackboard are congruent to -1 modulo $p$, then after any number of operations, all numbers on the blackboard will still be congruent to -1 modulo $p$.
Proof Let $x=\frac{a}{b}, y=\frac{c}{d}$ satisfy:
$(a, b)=(c, d)=1$, and $x \equiv y \equiv -1 \pmod{p}$.
Since $p \nmid 2bd$, and $p$ divides $(ad+bc+2bd) = d(a+b) + b(c+d)$, thus,
$$
\frac{x+y}{2} = \frac{ad+bc}{2bd} \equiv -1 \pmod{p},
$$

even if $ad+bc$ and $2bd$ are not coprime, the conclusion still holds after reducing $\frac{ad+bc}{2bd}$ to its simplest form.
And by $a+b \equiv c+d \equiv 0 \pmod{p}$, we have
$ad+bc \equiv (-b)d + b(-d) \equiv -2bd \not\equiv 0 \pmod{p}$.
Combining with $p$ dividing
$2ac + ad + bc = a(c+d) + c(a+b)$,
thus, $\frac{2xy}{x+y} = \frac{2ac}{ad+bc} \equiv -1 \pmod{p}$.
The proposition is proved.
If $m+n$ has an odd prime factor $p$, then
$$
\frac{m}{n}, \frac{n}{m} \equiv -1 \pmod{p}.
$$

By the above proposition, we know that after any number of operations, all numbers on the blackboard will still be congruent to -1 modulo $p$, thus, the number 1 cannot appear.

Next, prove: If $m+n$ has no odd prime factors (i.e., $m+n$ is a power of 2), then $m, n$ must meet the requirements.
In fact, let $m+n=2^k$. Since
$$
\begin{array}{l}
1 = \frac{n}{m+n} \cdot \frac{m}{n} + \frac{m}{m+n} \cdot \frac{n}{m} \\
= \frac{n}{2^k} \cdot \frac{m}{n} + \frac{m}{2^k} \cdot \frac{n}{m},
\end{array}
$$

thus, 1 is located at one of the points that divide the interval between $\frac{m}{n}$ and $\frac{n}{m}$ into $2^k$ equal parts.

Therefore, by selecting the largest number less than 1 and the smallest number greater than 1 from the existing numbers each time, and writing down their arithmetic mean, after $k$ operations, the number 1 will definitely appear on the blackboard.

In summary, the $m, n$ that meet the conditions are all positive integers $m, n$ such that $m+n$ is a power of 2.