5. On the set of natural numbers greater than 9, we define the function $f$ as follows: if $\overline{c_{1} c_{2} \ldots c_{s}}(s \geqslant 2)$ is the decimal representation of the number $n$, then $f(n)$ is the natural number obtained by replacing all occurrences of the digit $c_{1}$ in the number $n$ with the digit $c_{2}$, and all occurrences of the digit $c_{2}$ in the number $n$ with the digit $c_{1}$; if a leading zero appears in the resulting number after this operation, it is removed. (For example, $f(2375342)=3275243$ and $f(502305)=52350$.) Find all natural numbers that can appear as the value of the expression $\frac{n}{f(n)}$.

## First Grade - B Category
5. Suppose $\frac{n}{f(n)}=k \in \mathbb{N}$. Let $a$ and $b$ be the first two digits from the left in the $s$-digit number $n$. Note,

$$
(10 a+b) 10^{s-2} \leqslant n < (10 a+b+1) 10^{s-2}
$$

Since $f(n) \leqslant 9 s$, we have $k \leqslant 9 s / 10^{s-1}$. For $s \geqslant 3$, we have $9 s / 10^{s-1} < 1$, which is a contradiction. Therefore, $s=2$. Then, $10 a+b \leqslant n < 10 a+b+1$, and $f(n) = a + b$. Thus, we have:

$$
10 a + b = k (a + b)
$$

Rearranging, we get:

$$
(10 - k) a = (k - 1) b
$$

For $k > 10$, we have $(10 - k) a < 0$, which is a contradiction. For $k > 4$, we have $10 k - 1 > (10 - k) 9 + 1$, which contradicts the right inequality. Therefore, $k \leqslant 4$. An example for $k=1$ is $n=11$. For $k=2$, we have $8 a - 20$; however, then the first non-zero digit from the right in the number $B$ on the right side of the equation is 9, while on the left side it is 0, a contradiction. Thus, finally, we cannot find a corresponding $n$ for $k=4$.

Now consider the case $b=0$. From the above inequality, we have $10 - 2 k \leqslant (10 - k) a - k < 0 < (10 - k) a + 1 \leqslant 91 - 9 k$, so $k \in \{6, 7, 8, 9, 10\}$. For $k=6, 7, 9, 10$, we have examples, respectively, $n=108, 105, 405, 10$. Suppose now $k=8$. Then we have $2 a - 8 < 0$, so $a \in \{1, 2, 3\}$. Also, $s \geqslant 3$, because for numbers $\overline{a 0}$, we have $\frac{\overline{a 0}}{f(\overline{a 0})} = \frac{\overline{a 0}}{a} = 10$. Define the numbers $x, A$, and $B$ similarly as in the previous paragraph ($x$ is obtained by replacing all occurrences of the digit $a$ with 0, $A$ is obtained by replacing all occurrences of the digit $a$ with 1 and all other digits with 0, and $B$ is obtained by replacing all occurrences of the digit 0 with 1 and all other digits with 0, all in the number $n$ with the first two digits removed). Then we have $n = a 10^{s-1} + a A + x$ and $f(n) = a 10^{s-2} + a B + x$, so the condition $n = 8 f(n)$ reduces to

$$
2 a 10^{s-2} + a A = 8 a B + 7 x
$$

Suppose $n$ ends in the digit 0. Then, by the definition of the numbers $x, A$, and $B$, we have $10 \mid x, A$ and $10 \nmid B$, but this is a contradiction with the above equality (all terms except $8 a B$ are divisible by 10, and $8 a B$ is not because $B$ ends in the digit 1 and $a \in \{1, 2, 3\}$). Suppose now that $n$ ends in the digit $a$. Then we have $10 \mid x, B$ and $10 \nmid A$, which is again a contradiction with the above equality because $10 \nmid a A$. Finally, suppose $n$ ends in a digit different from 0 and $a$. Then we have $10 \mid A, B$ and $10 \nmid x$, and again a contradiction. Therefore, there are no solutions for $k=8$.

In conclusion, the only values of the expression $\frac{n}{f(n)}$ in the set of natural numbers are: $1, 6, 7, 9$, and 10.

## First Grade - Category B