18. (BUL) Determine all positive integers $n$ for which there exists an integer $m$ such that $2^{n}-1$ is a divisor of $m^{2}+9$.

Solution: 18. We claim that, if $2^{n}-1$ divides $m^{2}+9$ for some $m \in \mathbb{N}$, then $n$ must be a power of 2 . Suppose otherwise that $n$ has an odd divisor $d>1$. Then $2^{d}-1 \mid 2^{n}-1$ is also a divisor of $m^{2}+9=m^{2}+3^{2}$. However, $2^{d}-1$ has some prime divisor $p$ of the form $4 k-1$, and by a well-known fact, $p$ divides both $m$ and 3 . Hence $p=3$ divides $2^{d}-1$, which is impossible, because for $d$ odd, $2^{d} \equiv 2(\bmod 3)$. Hence $n=2^{r}$ for some $r \in \mathbb{N}$. Now let $n=2^{r}$. We prove the existence of $m$ by induction on $r$. The case $r=1$ is trivial. Now for any $r>1$ note that $2^{2^{r}}-1=\left(2^{2^{r-1}}-1\right)\left(2^{2^{r-1}}+\right.$ 1). The induction hypothesis claims that there exists an $m_{1}$ such that $2^{2^{r-1}}-1 \mid m_{1}^{2}+9$. We also observe that $2^{2^{r-1}}+1 \mid m_{2}^{2}+9$ for simple $m_{2}=3 \cdot 2^{2^{r-2}}$. By the Chinese remainder theorem, there is an $m \in \mathbb{N}$ that satisfies $m \equiv m_{1}\left(\bmod 2^{2^{r-1}}-1\right)$ and $m \equiv m_{2}\left(\bmod 2^{2^{r-1}}+1\right)$. It is easy to see that this $m^{2}+9$ will be divisible by both $2^{2^{r-1}}-1$ and $2^{2^{r-1}}+1$, i.e., that $2^{2^{r}}-1 \mid m^{2}+9$. This completes the induction.


19. (BLR) ${ }^{\mathrm{IMO} 3}$ For any positive integer $n$, let $\tau(n)$ denote the number of its positive divisors (including 1 and itself). Determine all positive integers $m$ for which there exists a positive integer $n$ such that $\frac{\tau\left(n^{2}\right)}{\tau(n)}=m$.

Solution: 19. For $n=p_{1}^{\alpha_{1}} p_{2}^{\alpha_{2}} \cdots p_{r}^{\alpha_{r}}$, where $p_{i}$ are distinct primes and $\alpha_{i}$ natural numbers, we have $\tau(n)=\left(\alpha_{1}+1\right) \cdots\left(\alpha_{r}+1\right)$ and $\tau\left(n^{2}\right)=\left(2 \alpha_{1}+1\right) \ldots\left(2 \alpha_{r}+1\right)$. Putting $k_{i}=\alpha_{i}+1$, the problem reduces to determining all natural values of $m$ that can be represented as  $$ m=\frac{2 k_{1}-1}{k_{1}} \cdot \frac{2 k_{2}-1}{k_{2}} \cdots \frac{2 k_{r}-1}{k_{r}} $$  Since the numerator $\tau\left(n^{2}\right)$ is odd, $m$ must be odd too. We claim that every odd $m$ has a representation of the form (1). The proof will be done by induction. This is clear for $m=1$. Now for every $m=2 k-1$ with $k$ odd the result follows easily, since $m=\frac{2 k-1}{k} \cdot k$, and $k$ can be written as (1). We cannot do the same if $k$ is even; however, in the case $m=4 k-1$ with $k$ odd, we can write it as $m=\frac{12 k-3}{6 k-1} \cdot \frac{6 k-1}{3 k} \cdot k$, and this works. In general, suppose that $m=2^{t} k-1$, with $k$ odd. Following the same pattern, we can write $m$ as  $$ m=\frac{2^{t}\left(2^{t}-1\right) k-\left(2^{t}-1\right)}{2^{t-1}\left(2^{t}-1\right) k-\left(2^{t-1}-1\right)} \cdots \frac{4\left(2^{t}-1\right) k-3}{2\left(2^{t}-1\right) k-1} \cdot \frac{2\left(2^{t}-1\right) k-1}{\left(2^{t}-1\right) k} \cdot k $$  The induction is finished. Hence $m$ can be represented as $\frac{\tau\left(n^{2}\right)}{\tau(n)}$ if and only if it is odd.


2. (POL) Let $A B C D$ be a cyclic quadrilateral. Let $E$ and $F$ be variable points on the sides $A B$ and $C D$, respectively, such that $A E: E B=C F$ : $F D$. Let $P$ be the point on the segment $E F$ such that $P E: P F=A B$ : $C D$. Prove that the ratio between the areas of triangles $A P D$ and $B P C$ does not depend on the choice of $E$ and $F$.

Solution: 2. If $A D$ and $B C$ are parallel, then $A B C D$ is an isosceles trapezoid with $A B=C D$, so $P$ is the midpoint of $E F$. Let $M$ and $N$ be the midpoints of $A B$ and $C D$. Then $M N \| B C$, and the distance $d(E, M N)$ equals the distance $d(F, M N)$ because $B$ and $D$ are the same distance from $M N$ and $E M / B M=F N / D N$. It follows that the midpoint $P$ of $E F$ lies on $M N$, and consequently $S_{A P D}: S_{B P C}=A D: B C$. If $A D$ and $B C$ are not parallel, then they meet at some point $Q$. It is plain that $\triangle Q A B \sim \triangle Q C D$, and since $A E / A B=C F / C D$, we also deduce that $\triangle Q A E \sim \triangle Q C F$. Therefore $\angle A Q E=\angle C Q F$. Further, from these similarities we obtain $Q E / Q F=Q A / Q C=A B / C D=P E / P F$, which in turn means that $Q P$ is the internal bisector of $\angle E Q F$. But since $\angle A Q E=\angle C Q F$, this is also the internal bisector of $\angle A Q B$. Hence $P$ is at equal distances from $A D$ and $B C$, so again $S_{A P D}: S_{B P C}=A D: B C$. Remark. The part $A B \| C D$ could also be regarded as a limiting case of the other part. Second solution. Denote $\lambda=\frac{A E}{A B}, A B=a, B C=b, C D=c, D A=d$, $\angle D A B=\alpha, \angle A B C=\beta$. Since $d(P, A D)=\frac{c \cdot d(E, A D)+a \cdot d(F, A D)}{a+c}$, we have $S_{A P D}=\frac{c S_{E A D}+a S_{F A D}}{a+c}=\frac{\lambda c S_{A B D}+(1-\lambda) a S_{A C D}}{a+c}$. Since $S_{A B D}=\frac{1}{2} a d \sin \alpha$ and $S_{A C D}=\frac{1}{2} c d \sin \beta$, we are led to $S_{A P D}=\frac{a c d}{a+c}[\lambda \sin \alpha+(1-\lambda) \sin \beta]$, and analogously $S_{B P C}=\frac{a b c}{a+c}[\lambda \sin \alpha+(1-\lambda) \sin \beta]$. Thus we obtain $S_{A P D}: S_{B P C}=d: b$.


20. (ARG) Prove that for each positive integer $n$, there exists a positive integer with the following properties: (i) It has exactly $n$ digits. (ii) None of the digits is 0 . (iii) It is divisible by the sum of its digits.

Solution: 20. We first consider the special case $n=3^{r}$. Then the simplest choice $\frac{10^{n}-1}{9}=$ $11 \ldots 1$ ( $n$ digits) works. This can be shown by induction: it is true for $r=$ 1, while the inductive step follows from $10^{3^{r}}-1=\left(10^{3^{r-1}}-1\right)\left(10^{2 \cdot 3^{r-1}}+\right.$ $10^{3^{r-1}}+1$ ), because the second factor is divisible by 3 . In the general case, let $k \geq n / 2$ be a positive integer and $a_{1}, \ldots, a_{n-k}$ be nonzero digits. We have  $$ \begin{aligned} A & =\left(10^{k}-1\right) \overline{a_{1} a_{2} \ldots a_{n-k}} \\ & =\overline{a_{1} a_{2} \ldots a_{n-k-1} a_{n-k}^{\prime} \underbrace{99 \ldots 99}_{2 k-n}} b_{1} b_{2} \ldots b_{n-k-1} b_{n-k}^{\prime} \end{aligned} $$  where $a_{n-k}^{\prime}=a_{n-k}-1, b_{i}=9-a_{i}$, and $b_{n-k}^{\prime}=9-a_{n-k}^{\prime}$. The sum of digits of $A$ equals $9 k$ independently of the choice of digits $a_{1}, \ldots, a_{n-k}$. Thus we need only choose $k \geq \frac{n}{2}$ and digits $a_{1}, \ldots, a_{n-k-1} \notin\{0,9\}$ and $a_{n-k} \in\{0,1\}$ in order for the conditions to be fulfilled. Let us choose  $$ k=\left\{\begin{array}{l} 3^{r}, \quad \text { if } 3^{r}<n \leq 2 \cdot 3^{r} \text { for some } r \in \mathbb{Z} \\ 2 \cdot 3^{r}, \text { if } 2 \cdot 3^{r}<n \leq 3^{r+1} \text { for some } r \in \mathbb{Z} \end{array}\right. $$  and $\overline{a_{1} a_{2} \ldots a_{n-k}}=\overline{22 \ldots 2}$. The number  $$ A=\overline{\underbrace{22 \ldots 2}_{n-k-1} 1 \underbrace{99 \ldots 99}_{2 k-n} \underbrace{77 \ldots 7}_{n-k-1} 8} $$  thus obtained is divisible by $2 \cdot\left(10^{k}-1\right)$, which is, as explained above, divisible by $18 \cdot 3^{r}$. Finally, the sum of digits of $A$ is either $9 \cdot 3^{r}$ or $18 \cdot 3^{r}$; thus $A$ has the desired properties.


21. (CAN) Let $a_{0}, a_{1}, a_{2}, \ldots$ be an increasing sequence of nonnegative integers such that every nonnegative integer can be expressed uniquely in the form $a_{i}+2 a_{j}+4 a_{k}$, where $i, j, k$ are not necessarily distinct. Determine $a_{1998}$.

Solution: 21. Such a sequence is obviously strictly increasing. We note that it must be unique. Indeed, given $a_{0}, a_{1}, \ldots, a_{n-1}$, then $a_{n}$ is the least positive integer not of the form $a_{i}+2 a_{j}+4 a_{k}, i, j, k<n$. We easily get that the first few $a_{n}$ 's are $0,1,8,9,64,65,72,73, \ldots$ Let $\left\{c_{n}\right\}$ be the increasing sequence of all positive integers that consist of zeros and ones in base 8 , i.e., those of the form $t_{0}+2^{3} t_{1}+\cdots+2^{3 q} t_{q}$ where $t_{i} \in\{0,1\}$. We claim that $a_{n}=c_{n}$. To prove this, it is enough to show that each $m \in \mathbb{N}$ can be uniquely written as $c_{i}+2 c_{j}+4 c_{k}$. If $m=t_{0}+2 t_{1}+\cdots+2^{r} t_{r}\left(t_{i} \in\{0,1\}\right)$, then $m=c_{i}+2 c_{j}+2^{2} c_{k}$ is obviously possible if and only if $c_{i}=t_{0}+2^{3} t_{3}+2^{6} t_{6}+\cdots, c_{j}=t_{1}+2^{3} t_{4}+\ldots$, and $c_{k}=t_{2}+2^{3} t_{5}+\cdots$. Hence for $n=s_{0}+2 s_{1}+\cdots+2^{r} s_{r}$ we have $a_{n}=s_{0}+8 s_{1}+\cdots+8^{r} s_{r}$. In particular, $1998=2+2^{2}+2^{3}+2^{6}+2^{7}+2^{8}+2^{9}+2^{10}$, so $a_{1998}=$ $8+8^{2}+8^{3}+8^{6}+8^{7}+8^{8}+8^{9}+8^{10}=1227096648$. Second solution. Define $f(x)=x^{a_{0}}+x^{a_{1}}+\cdots$. Then the assumed property of $\left\{a_{n}\right\}$ gives  $$ f(x) f\left(x^{2}\right) f\left(x^{4}\right)=\sum_{i, j, k} x^{a_{i}+2 a_{j}+4 a_{k}}=\sum_{n} x^{n}=\frac{1}{1-x} $$  We also get as a consequence $f\left(x^{2}\right) f\left(x^{4}\right) f\left(x^{8}\right)=\frac{1}{1-x^{2}}$, which gives $f(x)=$ $(1+x) f\left(x^{8}\right)$. Continuing this, we obtain  $$ f(x)=(1+x)\left(1+x^{8}\right)\left(1+x^{8^{2}}\right) \cdots $$  Hence the $a_{n}$ 's are integers that have only 0 's and 1 's in base 8.


22. (UKR) A rectangular array of numbers is given. In each row and each column, the sum of all numbers is an integer. Prove that each nonintegral number $x$ in the array can be changed into either $\lceil x\rceil$ or $\lfloor x\rfloor$ so that the row sums and column sums remain unchanged. (Note that $\lceil x\rceil$ is the least integer greater than or equal to $x$, while $\lfloor x\rfloor$ is the greatest integer less than or equal to $x$.)

Solution: 22. We can obviously change each $x$ into $\lfloor x\rfloor$ or $\lceil x\rceil$ so that the column sums remain unchanged. However, this does not necessarily match the row sums as well, so let us consider the sum $S$ of the absolute values of the changes in the row sums. It is easily seen that $S$ is even, and we want it to be 0 . A row may have a higher or lower sum than desired. Let us mark a cell by - if its entry $x$ was changed to $\lfloor x\rfloor$, and by + if it was changed to $\lceil x\rceil$ instead. We call a row $R_{2}$ accessible from a row $R_{1}$ if there is a column $C$ such that $C \cap R_{1}$ is marked + and $C \cap R_{2}$ is marked - . Note that a column containing a + must contain a - as well, because column sums are unchanged. Hence from each row with a higher sum we can access another row. Assume that the row sum in $R_{1}$ is higher. If $R_{1}, R_{2}, \ldots, R_{k}$ is a sequence of rows such that $R_{i+1}$ is accessible from $R_{i}$ via some column $C_{i}$ and such that the row sum in $R_{k}$ is lower, then by changing the signs in $C_{i} \cap R_{i}$ and $C_{i} \cap R_{i+1}(i=1,2, \ldots, k-1)$ we decrease $S$ by 2 , leaving column sums unchanged. We claim that such a sequence of rows always exists. Let $\mathcal{R}$ be the union of all rows that are accessible from $R_{1}$, directly or indirectly; let $\overline{\mathcal{R}}$ be the union of the remaining rows. We show that for any column $C$, the sum in $\mathcal{R} \cap C$ is not higher. If $\mathcal{R} \cap C$ contains no +'s, then this is clear. If $\mathcal{R} \cap C$ contains a + , since the rows of $\overline{\mathcal{R}}$ are not accessible, the set $\overline{\mathcal{R}} \cap C$ contains no -'s. It follows that the sum in $\overline{\mathcal{R}} \cap C$ is not lower, and since column sums are unchanged, we again come to the same conclusion. Thus the total sum in $\mathcal{R}$ is not higher. Therefore, there is a row in $\mathcal{R}$ with too low a sum, justifying our claim.


23. (BLR) Let $n$ be an integer greater than 2. A positive integer is said to be attainable if it is 1 or can be obtained from 1 by a sequence of operations with the following properties: (i) The first operation is either addition or multiplication. (ii) Thereafter, additions and multiplications are used alternately. (iii) In each addition one can choose independently whether to add 2 or $n$. (iv) In each multiplication, one can choose independently whether to multiply by 2 or by $n$. A positive integer that cannot be so obtained is said to be unattainable. (a) Prove that if $n \geq 9$, there are infinitely many unattainable positive integers. (b) Prove that if $n=3$, all positive integers except 7 are attainable.

Solution: 23. (a) If $n$ is even, then every odd integer is unattainable. Assume that $n \geq 9$ is odd. Let $a$ be obtained by addition from some $b$, and $b$ from $c$ by multiplication. Then $a$ is $2 c+2,2 c+n, n c+2$, or $n c+n$, and is in every case congruent to $2 c+2$ modulo $n-2$. In particular, if $a \equiv-2$ $(\bmod n-2)$, then also $b \equiv-4$ and $c \equiv-2(\bmod n-2)$. Now consider any $a=k n(n-2)-2$, where $k$ is odd. If it is attainable, but not divisible by 2 or $n$, it must have been obtained by addition. Thus all predecessors of $a$ are congruent to either -2 or $-4(\bmod$ $n-2$ ), and none of them equals 1 , a contradiction. (b) Call an attainable number addy if the last operation is addition, and multy if the last operation is multiplication. We prove the following claims by simultaneous induction on $k$ : (1) $n=6 k$ is both addy and multy; (2) $n=6 k+1$ is addy for $k \geq 2$; (3) $n=6 k+2$ is addy for $k \geq 1$; (4) $n=6 k+3$ is addy; (5) $n=6 k+4$ is multy for $k \geq 1$; (6) $n=6 k+5$ is addy.  The cases $k \leq 1$ are easily verified. For $k \geq 2$, suppose all six statements hold up to $k-1$.  Since $6 k-3$ is addy, $6 k$ is multy. Next, $6 k-2$ is multy, so both $6 k=(6 k-2)+2$ and $6 k+1=(6 k-2)+3$ are addy. Since $6 k$ is multy, both $6 k+2$ and $6 k+3$ are addy. Number $6 k+4=2 \cdot(3 k+2)$ is multy, because $3 k+2$ is addy (being either $6 l+2$ or $6 l+5)$. Finally, we have $6 k+5=3 \cdot(2 k+1)+2$. Since $2 k+1$ is $6 l+1,6 l+3$, or $6 l+5$, it is addy except for 7 . Hence $6 k+5$ is addy except possibly for 23 . But $23=((1 \cdot 2+2) \cdot 2+2) \cdot 2+3$ is also addy. This completes the induction. Now 1 is given and $2=1 \cdot 2,4=1+3$. It is easily checked that 7 is not attainable, and hence it is the only unattainable number.


24. (SWE) Cards numbered 1 to 9 are arranged at random in a row. In a move, one may choose any block of consecutive cards whose numbers are in ascending or descending order, and switch the block around. For example, $91 \underline{6532748}$ may be changed to $91 \underline{3562748}$. Prove that in at most 12 moves, one can arrange the 9 cards so that their numbers are in ascending or descending order.

Solution: 24. Let $f(n)$ be the minimum number of moves needed to monotonize any permutation of $n$ distinct numbers. Let us be given a permutation $\pi$ of $\{1,2, \ldots, n\}$, and let $k$ be the first element of $\pi$. In $f(n-1)$ moves, we can transform $\pi$ to either $(k, 1,2, \ldots, k-1, k+1, \ldots, n)$ or $(k, n, n-1, \ldots, k+$ $1, k-1, \ldots, 1)$. Now the former can be changed to $(k, k-1, \ldots, 2,1, k+$ $1, \ldots, n)$, which is then monotonized in the next move. Similarly, the latter also can be monotonized in two moves. It follows that $f(n) \leq f(n-1)+2$. Thus we shall be done if we show that $f(5) \leq 4$. First we note that $f(3)=1$. Consider a permutation of $\{1,2,3,4\}$. If either 1 or 4 is the first or the last element, we need one move to monotonize the other three elements, and at most one more to monotonize the whole permutation. Of the remaining four permutations, $(2,1,4,3)$ and $(3,4,1,2)$ can also be monotonized in two moves. The permutations $(2,4,1,3)$ and $(3,1,4,2)$ require 3 moves, but by this we can choose whether to change them into $(1,2,3,4)$ or $(4,3,2,1)$. We now consider a permutation of $\{1,2,3,4,5\}$. If either 1 or 5 is in the first or last position, we can monotonize the rest in 3 moves, but in such a way that the whole permutation can be monotonized in the next move. If this is not the case, then either 1 or 5 is in the second or fourth position. Then we simply switch it to the outside in one move and continue as in the former case. Hence $f(5)=4$, as desired.


25. (NZL) Let $U=\{1,2, \ldots, n\}$, where $n \geq 3$. A subset $S$ of $U$ is said to be split by an arrangement of the elements of $U$ if an element not in $S$ occurs in the arrangement somewhere between two elements of $S$. For example, 13542 splits $\{1,2,3\}$ but not $\{3,4,5\}$. Prove that for any $n-2$ subsets of $U$, each containing at least 2 and at most $n-1$ elements, there is an arrangement of the elements of $U$ that splits all of them.

Solution: 25. We use induction on $n$. For $n=3$, we have a single two-element subset $\{i, j\}$ that is split by $(i, k, j)$ (where $k$ is the third element of $U$ ). Assume that the result holds for some $n \geq 3$, and consider a family $\mathcal{F}$ of $n-1$ proper subsets of $U=\{1,2, \ldots, n+1\}$, each with at least 2 elements. To continue the induction, we need an element $a \in U$ that is contained in all $n$-element subsets of $\mathcal{F}$, but in at most one of the two-element subsets. We claim that such an $a$ exists. Let $\mathcal{F}$ contain $k n$-element subsets and $m 2$-element subsets $(k+m \leq n-1)$. The intersection of the $n$-element subsets contains exactly $n+1-k \geq m+2$ elements. On the other hand, at most $m$ elements belong to more than one 2 -element subset, which justifies our claim.  Now let $A$ be the 2-element subset that contains $a$, if it exists; otherwise, let $A$ be any subset from $\mathcal{F}$ containing $a$. Excluding $a$ from all the subsets from $\mathcal{F} \backslash\{A\}$, we get at most $n-2$ subsets of $U \backslash\{a\}$ with at least 2 and at most $n-1$ elements. By the inductive hypothesis, we can arrange $U \backslash\{a\}$ so that we split all the subsets of $\mathcal{F}$ except $A$. It remains to place $a$, and we shall make a desired arrangement if we put it anywhere away from $A$.


26. (IND) ${ }^{\mathrm{IMO} 2}$ In a contest, there are $m$ candidates and $n$ judges, where $n \geq 3$ is an odd integer. Each candidate is evaluated by each judge as either pass or fail. Suppose that each pair of judges agrees on at most $k$ candidates. Prove that $\frac{k}{m} \geq \frac{n-1}{2 n}$.

Solution: 26. Put $n=2 r+1$. Since each of the $\binom{n}{2}$ pairs of judges agrees on at most two candidates, the total number of agreements is at most $k\binom{n}{2}$. On the other hand, if the $i$ th candidate is passed by $x_{i}$ judges and failed by $n-x_{i}$ judges, then the number of agreements on this candidate equals  $$ \binom{x_{i}}{2}+\binom{n-x_{i}}{2}=\frac{x_{i}^{2}+\left(n-x_{i}\right)^{2}-n}{2} \geq \frac{r^{2}+(n-r)^{2}-n}{2}=\frac{(n-1)^{2}}{4} . $$  Therefore the total number of agreements is at least $\frac{m(n-1)^{2}}{4}$, which implies that  $$ k\binom{n}{2} \geq \frac{m(n-1)^{2}}{4}, \quad \text { hence } \quad \frac{k}{m} \geq \frac{n-1}{2 n} . $$  Remark. The obtained inequality is sharp. Indeed, if $m=\binom{2 r+1}{r}$ and each candidate is passed by a different subset of $r$ judges, we get equality. A similar example shows that the result is not valid for even $n$. In that case the weaker estimate $\frac{k}{m} \geq \frac{n-2}{2 n-2}$ holds.


27. (BLR) Ten points such that no three of them lie on a line are marked in the plane. Each pair of points is connected with a segment. Each of these segments is painted with one of $k$ colors in such a way that for any $k$ of the ten points, there are $k$ segments each joining two of them with no two being painted the same color. Determine all integers $k, 1 \leq k \leq 10$, for which this is possible.

Solution: 27. Since this is essentially a graph problem, we call the points and segments vertices and edges of the graph. We first prove that the task is impossible if $k \leq 4$. Cases $k \leq 2$ are trivial. If $k=3$, then among the edges from a vertex $A$ there are two of the same color, say $A B$ and $A C$, so we don't have all the three colors among the edges joining $A, B, C$. Now let $k=4$, and assume that there is a desired coloring. Consider the edges incident with a vertex $A$. At least three of them have the same color, say blue. Suppose that four of them, $A B, A C, A D, A E$, are blue. There is a blue edge, say $B C$, among the ones joining $B, C, D, E$. Then four of the edges joining $A, B, C, D$ are blue, and we cannot complete the coloring. So, exactly three edges from $A$ are blue: $A B, A C, A D$. Also, of the edges connecting any three of the 6 vertices other than $A, B, C, D$, one is blue (because the edges joining them with $A$ are not so). By a classical result, there is a blue triangle $E F G$ with vertices among these six. Now one of $E B, E C, E D$ must be blue as well, because none of $B C, B D, C D$ is. Let it be $E B$. Then four of the edges joining $B, E, F, G$ are blue, which is impossible. For $k=5$ the task is possible. Label the vertices $0,1, \ldots, 9$. For each color, we divide the vertices into four groups and paint in this color every edge joining two from the same group, as shown below. Then among any 5 vertices, 2 must belong to the same group, and the edge connecting them has the considered color.  | yellow: | 011220 | 366993 | 57 | 48 | | :--- | :--- | :--- | :--- | :--- | | red: | 233442 | 588115 | 79 | 60 | | blue: | 455664 | 700337 | 91 | 82 | | green: | 677886 | 922559 | 13 | 04 | | orange: | 899008 | 144771 | 35 | 26. |  A desired coloring can be made for $k \geq 6$ as well. Paint the edge $i j$ in the $(i+j)$ th color for $i<j \leq 8$, and in the $2 i$ th color if $j=9$ (the addition being modulo 9 ). We can ignore the edges painted with the extra colors. Then the edges of one color appear as five disjoint segments, so that any complete $k$-graph for $k \geq 5$ contains one of them.


28. (IRN) A solitaire game is played on an $m \times n$ rectangular board, using $m n$ markers that are white on one side and black on the other. Initially, each square of the board contains a marker with its white side up, except for one corner square, which contains a marker with its black side up. In each move, one can take away one marker with its black side up, but must then turn over all markers that are in squares having an edge in common with the square of the removed marker. Determine all pairs $(m, n)$ of positive integers such that all markers can be removed from the board.

Solution: 28. Let $A$ be the number of markers with white side up, and $B$ the number of pairs of markers whose squares share a side. We claim that $A+B$ does not change its parity as the game progresses. Suppose that in some move we remove a marker that has exactly $k$ neighbors, among them $r$ with white side up ( $0 \leq r \leq k \leq 4$ ). Of course, this marker has its black side up. When it is removed, the $r$ white markers get black side up, while the $k-r$ black ones become white. Thus $A$ changes by $k-2 r$. As for $B$, it decreases by $k$. It follows that $A$ decreases by $2 r$ and preserves its parity, as claimed. Initially, $A=m n-1$ and $B=m(n-1)+n(m-1)$; hence $A+B$ equals $3 m n-m-n-1$. If we succeed in removing all the markers, we end up with $A+B=0$. Hence $3 m n-m-n-1=(m-1)(n-1)+2(m n-1)$ must be even, or equivalently at least one of $m$ and $n$ is odd. On the other hand, the game can be finished successfully if $m$ or $n$ is odd. Assume that $m$ is odd. As shown in the picture, we can arrive at the position (1) in $m$ moves; with $\frac{m+1}{2}$ moves we reduce it to the position $\left(1 \frac{1}{2}\right)$, and with the next $\frac{m-1}{2}$ moves to the position (2). We continue until we empty all the columns. ![](https://cdn.mathpix.com/cropped/2024_11_18_8e985d6b9c83aa3e9d0eg-654.jpg?height=336&width=897&top_left_y=1605&top_left_x=342)


3. (UKR) ${ }^{\mathrm{IMO}}$ Let $I$ be the incenter of triangle $A B C$. Let $K, L$, and $M$ be the points of tangency of the incircle of $A B C$ with $A B, B C$, and $C A$, respectively. The line $t$ passes through $B$ and is parallel to $K L$. The lines $M K$ and $M L$ intersect $t$ at the points $R$ and $S$. Prove that $\angle R I S$ is acute.

Solution: 3. Lemma. If $U, W, V$ are three points on a line $l$ in this order, and $X$ a point in the plane with $X W \perp U V$, then $\angle U X V<90^{\circ}$ if and only if $X W^{2}>U W \cdot V W$. Proof. Let $X W^{2}>U W \cdot V W$, and let $X_{0}$ be a point on the segment $X W$ such that $X_{0} W^{2} \geq U W \cdot V W$. Then $X_{0} W / U W=V W / X_{0} W$, so that triangles $X_{0} W U$ and $V W X_{0}$ are similar. Thus $\angle U X_{0} V=\angle U X_{0} W+$ $\angle W U X_{0}=90^{\circ}$, which immediately implies that $\angle U X V<90^{\circ}$. Similarly, if $X W^{2} \leq U W \cdot V W$, then $\angle U X V \geq 90^{\circ}$. Since $B I \perp R S$, it will be enough by the lemma to show that $B I^{2}>$ $B R \cdot B S$. Note that $\triangle B K R \sim \triangle B S L$ : in fact, we have $\angle K B R=\angle S B L=$ $90^{\circ}-\beta / 2$ and $\angle B K R=\angle A K M=\angle K L M=\angle B S L=90^{\circ}-\alpha / 2$. In particular, we obtain $B R / B K=B L / B S=B K / B S$, so that $B R \cdot B S=$ $B K^{2}<B I^{2}$ 。 Second solution. Let $E, F$ be the midpoints of $K M$ and $L M$ respectively. The quadrilaterals $R B I E$ and $S B I F$ are inscribed in the circles with diameters $I R$ and $I S$. Now we have $\angle R I S=\angle R M S+\angle I R M+\angle I S M=$ $90^{\circ}-\beta / 2+\angle I B E+\angle I B F=90^{\circ}-\beta / 2+\angle E B F$. On the other hand, $B E$ and $B F$ are medians in $\triangle B K M$ and $\triangle B L M$ in which $B M>B K$ and $B M>B L$. We conclude that $\angle M B E<\frac{1}{2} \angle M B K$ and $\angle M B F<\frac{1}{2} \angle M B L$. Adding these two inequalities gives $\angle E B F<$ $\beta / 2$. Therefore $\angle R I S<90^{\circ}$. Remark. It can be shown (using vectors) that the statement remains true for an arbitrary line $t$ passing through $B$.


4. (ARM) Let $M$ and $N$ be points inside triangle $A B C$ such that  $$ \angle M A B=\angle N A C \quad \text { and } \quad \angle M B A=\angle N B C . $$  Prove that  $$ \frac{A M \cdot A N}{A B \cdot A C}+\frac{B M \cdot B N}{B A \cdot B C}+\frac{C M \cdot C N}{C A \cdot C B}=1 $$

Solution: 4. Let $K$ be the point on the ray $B N$ with $\angle B C K=\angle B M A$. Since $\angle K B C=\angle A B M$, we get $\triangle B C K \sim \triangle B M A$. It follows that $B C / B M=$ $B K / B A$, which implies that also $\triangle B A K \sim \triangle B M C$. The quadrilateral $A N C K$ is cyclic, because $\angle B K C=\angle B A M=\angle N A C$. Then by Ptolemy's theorem we obtain  $$ A C \cdot B K=A C \cdot B N+A N \cdot C K+C N \cdot A K $$  On the other hand, from the similarities noted above we get  $$ C K=\frac{B C \cdot A M}{B M}, A K=\frac{A B \cdot C M}{B M} \text { and } B K=\frac{A B \cdot B C}{B M} . $$  After substitution of these values, the equality (1) becomes  $$ \frac{A B \cdot B C \cdot A C}{B M}=A C \cdot B N+\frac{B C \cdot A M \cdot A N}{B M}+\frac{A B \cdot C M \cdot C N}{B M}, $$  which is exactly the equality we must prove multiplied by $\frac{A B \cdot B C \cdot C A}{B M}$.


5. (FRA) Let $A B C$ be a triangle, $H$ its orthocenter, $O$ its circumcenter, and $R$ its circumradius. Let $D$ be the reflection of $A$ across $B C, E$ that of $B$ across $C A$, and $F$ that of $C$ across $A B$. Prove that $D, E$, and $F$ are collinear if and only if $O H=2 R$.

Solution: 5. Let $G$ be the centroid of $\triangle A B C$ and $\mathcal{H}$ the homothety with center $G$ and ratio $-\frac{1}{2}$. It is well-known that $\mathcal{H}$ maps $H$ into $O$. For every other point $X$, let us denote by $X^{\prime}$ its image under $\mathcal{H}$. Also, let $A_{2} B_{2} C_{2}$ be the triangle in which $A, B, C$ are the midpoints of $B_{2} C_{2}, C_{2} A_{2}$, and $A_{2} B_{2}$, respectively. It is clear that $A^{\prime}, B^{\prime}, C^{\prime}$ are the midpoints of sides $B C, C A, A B$ respectively. Furthermore, $D^{\prime}$ is the reflection of $A^{\prime}$ across $B^{\prime} C^{\prime}$. Thus $D^{\prime}$ must lie on $B_{2} C_{2}$ and $A^{\prime} D^{\prime} \perp$ ![](https://cdn.mathpix.com/cropped/2024_11_18_8e985d6b9c83aa3e9d0eg-643.jpg?height=484&width=552&top_left_y=612&top_left_x=806) $B_{2} C_{2}$. However, it also holds that $O A^{\prime} \perp B_{2} C_{2}$, so we conclude that $O, D^{\prime}, A^{\prime}$ are collinear and $D^{\prime}$ is the projection of $O$ on $B_{2} C_{2}$. Analogously, $E^{\prime}, F^{\prime}$ are the projections of $O$ on $C_{2} A_{2}$ and $A_{2} B_{2}$. Now we apply Simson's theorem. It claims that $D^{\prime}, E^{\prime}, F^{\prime}$ are collinear (which is equivalent to $D, E, F$ being collinear) if and only if $O$ lies on the circumcircle of $A_{2} B_{2} C_{2}$. However, this circumcircle is centered at $H$ with radius $2 R$, so the last condition is equivalent to $H O=2 R$.


6. (POL) Let $A B C D E F$ be a convex hexagon such that $\angle B+\angle D+\angle F=$ $360^{\circ}$ and  $$ \frac{A B}{B C} \cdot \frac{C D}{D E} \cdot \frac{E F}{F A}=1 $$  Prove that  $$ \frac{B C}{C A} \cdot \frac{A E}{E F} \cdot \frac{F D}{D B}=1 $$

Solution: 6. Let $P$ be the point such that $\triangle C D P$ and $\triangle C B A$ are similar and equally oriented. Since then $\angle D C P=\angle B C A$ and $\frac{B C}{C A}=\frac{D C}{C P}$, it follows that $\angle A C P=\angle B C D$ and $\frac{A C}{C P}=\frac{B C}{C D}$, so $\triangle A C P \sim \triangle B C D$. In particular, $\frac{B C}{C A}=\frac{D B}{P A}$. Furthermore, by the conditions of the problem we have $\angle E D P=360^{\circ}-$ $\angle B-\angle D=\angle F$ and $\frac{P D}{D E}=\frac{P D}{C D} \cdot \frac{C D}{D E}=\frac{A B}{B C} \cdot \frac{C D}{D E}=\frac{A F}{F E}$. Therefore $\triangle E D P \sim \triangle E F A$ as well, so that similarly as above we conclude that $\triangle A E P \sim \triangle F E D$ and consequently $\frac{A E}{E F}=\frac{P A}{F D}$. Finally, $\frac{B C}{C A} \cdot \frac{A E}{E F} \cdot \frac{F D}{D B}=\frac{D B}{P A} \cdot \frac{P A}{F D} \cdot \frac{F D}{D B}=1$. Second solution. Let $a, b, c, d, e, f$ be the complex coordinates of $A, B$, $C, D, E, F$, respectively. The condition of the problem implies that $\frac{a-b}{b-c}$. $\frac{c-d}{d-e} \cdot \frac{e-f}{f-a}=-1$. On the other hand, since $(a-b)(c-d)(e-f)+(b-c)(d-e)(f-a)=$ $(b-c)(a-e)(f-d)+(c-a)(e-f)(d-b)$ holds identically, we immediately deduce that $\frac{b-c}{c-a} \cdot \frac{a-e}{e-f} \cdot \frac{f-d}{d-b}=-1$. Taking absolute values gives $\frac{B C}{C A} \cdot \frac{A E}{E F}$. $\frac{F D}{D B}=1$.


7. (GBR) Let $A B C$ be a triangle such that $\angle A C B=2 \angle A B C$. Let $D$ be the point on the side $B C$ such that $C D=2 B D$. The segment $A D$ is extended to $E$ so that $A D=D E$. Prove that  $$ \angle E C B+180^{\circ}=2 \angle E B C . $$

Solution: 7. We shall use the following result.  Lemma. In a triangle $A B C$ with $B C=a, C A=b$, and $A B=c$, i. $\angle C=2 \angle B$ if and only if $c^{2}=b^{2}+a b$; ii. $\angle C+180^{\circ}=2 \angle B$ if and only if $c^{2}=b^{2}-a b$.  Proof. i. Take a point $D$ on the extension of $B C$ over $C$ such that $C D=b$. The condition $\angle C=2 \angle B$ is equivalent to $\angle A D C=\frac{1}{2} \angle C=\angle B$, and thus to $A D=A B=c$. This is further equivalent to triangles $C A D$ and $A B D$ being similar, so $C A / A D=A B / B D$, i.e., $c^{2}=$ $b(a+b)$. ii. Take a point $E$ on the ray $C B$ such that $C E=b$. As above, $\angle C+180^{\circ}=2 \angle B$ if and only if $\triangle C A E \sim \triangle A B E$, which is equivalent to $E B / B A=E A / A C$, or $c^{2}=b(b-a)$. Let $F, G$ be points on the ray $C B$ such that $C F=\frac{1}{3} a$ and $C G=\frac{4}{3} a$. Set $B C=a, C A=b, A B=c, E C=b_{1}$, and $E B=c_{1}$. By the lemma it follows that $c^{2}=b^{2}+a b$. Also $b_{1}=A G$ and $c_{1}=A F$, so Stewart's theorem gives us $c_{1}^{2}=\frac{2}{3} b^{2}+\frac{1}{3} c^{2}-\frac{2}{9} a^{2}=b^{2}+\frac{1}{3} a b-\frac{2}{9} a^{2}$ and $b_{1}^{2}=$ $-\frac{1}{3} b^{2}+\frac{4}{3} c^{2}+\frac{4}{9} a^{2}=b^{2}+\frac{4}{3} a b+\frac{4}{9} a^{2}$. It follows that $b_{1}=\frac{2}{3} a+b$ and $c_{1}^{2}=b_{1}^{2}-\left(a b+\frac{2}{3} a^{2}\right)=b_{1}^{2}-a b_{1}$. The statement of the problem follows immediately by the lemma.


8. (IND) Let $A B C$ be a triangle such that $\angle A=90^{\circ}$ and $\angle B<\angle C$. The tangent at $A$ to its circumcircle $\omega$ meets the line $B C$ at $D$. Let $E$ be the reflection of $A$ across $B C, X$ the foot of the perpendicular from $A$ to $B E$, and $Y$ the midpoint of $A X$. Let the line $B Y$ meet $\omega$ again at $Z$. Prove that the line $B D$ is tangent to the circumcircle of triangle $A D Z$.

Solution: 8. Let $M$ be the point of intersection of $A E$ and $B C$, and let $N$ be the point on $\omega$ diametrically opposite $A$. Since $\angle B<\angle C$, points $N$ and $B$ are on the same side of $A E$. Furthermore, $\angle N A E=\angle B A X=$ $90^{\circ}-\angle A B E$; hence the triangles $N A E$ and $B A X$ are similar. Consequently, $\triangle B A Y$ and $\triangle N A M$ are also similar, since $M$ is the midpoint ![](https://cdn.mathpix.com/cropped/2024_11_18_8e985d6b9c83aa3e9d0eg-644.jpg?height=279&width=555&top_left_y=1171&top_left_x=802) of $A E$. Thus $\angle A N Z=\angle A B Z=\angle A B Y=\angle A N M$, implying that $N, M, Z$ are collinear. Now we have $\angle Z M D=90^{\circ}-\angle Z M A=\angle E A Z=$ $\angle Z E D$ (the last equality because $E D$ is tangent to $\omega$ ); hence $Z M E D$ is a cyclic quadrilateral. It follows that $\angle Z D M=\angle Z E A=\angle Z A D$, which is enough to conclude that $M D$ is tangent to the circumcircle of $A Z D$. Remark. The statement remains valid if $\angle B \geq \angle C$.


9. (MON) Let $a_{1}, a_{2}, \ldots, a_{n}$ be positive real numbers such that $a_{1}+a_{2}+$ $\cdots+a_{n}<1$. Prove that  $$ \frac{a_{1} a_{2} \cdots a_{n}\left[1-\left(a_{1}+a_{2}+\cdots+a_{n}\right)\right]}{\left(a_{1}+a_{2}+\cdots+a_{n}\right)\left(1-a_{1}\right)\left(1-a_{2}\right) \cdots\left(1-a_{n}\right)} \leq \frac{1}{n^{n+1}} . $$

Solution: 9. Set $a_{n+1}=1-\left(a_{1}+\cdots+a_{n}\right)$. Then $a_{n+1}>0$, and the desired inequality becomes  $$ \frac{a_{1} a_{2} \cdots a_{n+1}}{\left(1-a_{1}\right)\left(1-a_{2}\right) \cdots\left(1-a_{n+1}\right)} \leq \frac{1}{n^{n+1}} $$  To prove it, we observe that $1-a_{i}=a_{1}+\cdots+a_{i-1}+a_{i+1}+\cdots+a_{n+1} \geq n \sqrt[n]{a_{1} \cdots a_{i-1} a_{i+1} \cdots a_{n+1}}$. Multiplying these inequalities for $i=1,2, \ldots, n+1$, we get exactly the inequality we need.


1. $\mathbf{N} \mathbf{1}(\mathbf{T W N}){ }^{\mathrm{IMO}+4}$ Find all pairs of positive integers $(x, p)$ such that $p$ is a prime, $x \leq 2 p$, and $x^{p-1}$ is a divisor of $(p-1)^{x}+1$.

Solution: 1. Obviously $(1, p)$ (where $p$ is an arbitrary prime) and $(2,2)$ are solutions and the only solutions to the problem for $x<3$ or $p<3$. Let us now assume $x, p \geq 3$. Since $p$ is odd, $(p-1)^{x}+1$ is odd, and hence $x$ is odd. Let $q$ be the largest prime divisor of $x$, which also must be odd. We have $q|x| x^{p-1} \mid(p-1)^{x}+1 \Rightarrow(p-1)^{x} \equiv-1(\bmod q)$. Also from Fermat's little theorem $(p-1)^{q-1} \equiv 1(\bmod q)$. Since $q-1$ and $x$ are coprime, there exist integers $\alpha, \beta$ such that $x \alpha=(q-1) \beta+1$. We also note that $\alpha$ must be odd. We now have $p-1 \equiv(p-1)^{(q-1) \beta+1} \equiv(p-1)^{x \alpha} \equiv-1(\bmod q)$ and hence $q \mid p \Rightarrow q=p$. Since $x$ is odd, $p \mid x$, and $x \leq 2 p$, it follows $x=p$ for all $x, p \geq 3$. Thus  $$ p^{p-1} \left\lvert\,(p-1)^{x}+1=p^{2} \cdot\left(p^{p-2}-\binom{p}{1} p^{p-1}+\cdots-\binom{p}{p-2}+1\right) .\right. $$  Since the expression in parenthesis is not divisible by $p$, it follows that $p^{p-1} \mid p^{2}$ and hence $p \leq 3$. One can easily verify that $(3,3)$ is a valid solution. We have shown that the only solutions are $(1, p),(2,2)$, and $(3,3)$, where $p$ is an arbitrary prime.


10. G4 (GBR) For a triangle $T=A B C$ we take the point $X$ on the side $(A B)$ such that $A X / X B=4 / 5$, the point $Y$ on the segment $(C X)$ such that $C Y=2 Y X$, and, if possible, the point $Z$ on the ray ( $C A$ such that $\measuredangle C X Z=180^{\circ}-\measuredangle A B C$. We denote by $\Sigma$ the set of all triangles $T$ for which $\measuredangle X Y Z=45^{\circ}$. Prove that all the triangles from $\Sigma$ are similar and find the measure of their smallest angle.

Solution: 10. We use the following lemma.  Lemma. Let $A B C$ be a triangle and $X \in A B$ such that $\overrightarrow{A X}: \overrightarrow{X B}=m: n$. Then $(m+n) \cot \angle C X B=n \cot A-m \cot B$ and $m \cot \angle A C X=$ $(n+m) \cot C+n \cot A$. Proof. Let $C D$ be the altitude from $C$ and $h$ its length. Then using oriented segments we have $A X=A D+D X=h \cot A-h \cot \angle C X B$ and $B X=B D+D X=h \cot B+h \cot \angle C X B$. The first formula in the lemma now follows from $n \cdot A X=m \cdot B X$. The second formula immediately follows from the first part applied to the triangle $A C X$ and the point $X^{\prime} \in A C$ such that $X X^{\prime} \| B C$. Let us set $\cot A=x, \cot B=y$, and $\cot C=z$. Applying the second formula in the lemma to $\triangle A B C$ and the point $X$, we obtain $4 \cot \angle A C X=$ $9 z+5 x$. Applying the first formula in the lemma to $\triangle C X Z$ and the point $Y$ and using $\angle X Y Z=45^{\circ}$ and $\cot \angle C X Z=-y$, we obtain $3 \cot \angle X Y Z=$ $\cot \angle A C X-2 \cot \angle C X Z=\frac{9 z+5 x}{4}+2 y \Rightarrow 5 x+8 y+9 z=12$. We now use the well-known relation for cotangents of a triangle $x y+y z+$ $x z=1$ to get $9=9(x+y) z+9 x y=(x+y)(12-5 x-8 z)+9 x y=9 \Rightarrow$ $(4 y+x-3)^{2}+9(x-1)^{2}=0 \Rightarrow x=1, y=\frac{1}{2}, z=\frac{1}{3}$. It follows that $x, y$, and $z$ have fixed values, and hence all triangles $T$ in $\Sigma$ are similar, with their smallest angle $A$ having cotangent 1 and thus being equal to $\angle A=45^{\circ}$.


11. G5 (FRA) Let $A B C$ be a triangle, $\Omega$ its incircle and $\Omega_{a}, \Omega_{b}, \Omega_{c}$ three circles three circles orthogonal to $\Omega$ passing through $B$ and $C, A$ and $C$, and $A$ and $B$ respectively. The circles $\Omega_{a}, \Omega_{b}$ meet again in $C^{\prime}$; in the same way we obtain the points $B^{\prime}$ and $A^{\prime}$. Prove that the radius of the circumcircle of $A^{\prime} B^{\prime} C^{\prime}$ is half the radius of $\Omega$.

Solution: 11. Let $\Omega(I, r)$ be the incircle of $\triangle A B C$. Let $D, E$, and $F$ denote the points where $\Omega$ touches $B C, A C$, and $A B$, respectively. Let $P, Q$, and $R$ denote the midpoints of $E F, D F$, and $D E$ respectively. We prove that $\Omega_{a}$ passes through $Q$ and $R$. Since $\triangle I Q D \sim \triangle I D B$ and $\triangle I R D \sim \triangle I D C$, we obtain $I Q \cdot I B=I R \cdot I C=r^{2}$. We conclude that $B, C, Q$, and $R$ lie on a single circle $\Gamma_{a}$. Moreover, since the power of $I$ with respect to $\Gamma_{a}$ is $r^{2}$, it follows for a tangent $I X$ from $I$ to $\Gamma_{a}$ that $X$ lies on $\Omega$ and hence $\Omega$ is perpendicular to $\Gamma_{a}$. From the uniqueness of $\Omega_{a}$ it follows that $\Omega_{a}=\Gamma_{a}$. Thus $\Omega_{a}$ contains $Q$ and $R$. Similarly $\Omega_{b}$ contains $P$ and $R$ and $\Omega_{c}$ contains $P$ and $Q$. Hence, $A^{\prime}=P, B^{\prime}=Q$ and $C^{\prime}=R$. Therefore the radius of the circumcircle of $\triangle A^{\prime} B^{\prime} C^{\prime}$ is half the radius of $\Omega$.


12. G6 (RUS) ${ }^{\mathrm{IMO} 5}$ Two circles $\Omega_{1}$ and $\Omega_{2}$ touch internally the circle $\Omega$ in $M$ and $N$, and the center of $\Omega_{2}$ is on $\Omega_{1}$. The common chord of the circles $\Omega_{1}$ and $\Omega_{2}$ intersects $\Omega$ in $A$ and $B . M A$ and $M B$ intersect $\Omega_{1}$ in $C$ and $D$. Prove that $\Omega_{2}$ is tangent to $C D$.

Solution: 12. We first introduce the following lemmas.  Lemma 1. Let $A B C$ be a triangle, $I$ its inenter and $I_{a}$ the center of the excircle touching $B C$. Let $A^{\prime}$ be the center of the arc $\widehat{B C}$ of the circumcircle not containing $A$. Then $A^{\prime} B=A^{\prime} C=A^{\prime} I=A^{\prime} I_{a}$. Proof. The result follows from a straightforward calculation of the relevant angles. Lemma 2. Let two circles $k_{1}$ and $k_{2}$ meet each other at points $X$ and $Y$ and touch a circle $k$ internally in points $M$ and $N$, respectively. Let $A$ be one of the intersections of the line $X Y$ with $k$. Let $A M$ and $A N$ intersect $k_{1}$ and $k_{2}$ respectively at $C$ and $E$. Then $C E$ is a common tangent of $k_{1}$ and $k_{2}$. Proof. Since $A C \cdot A M=A X \cdot A Y=A E \cdot A N$, the points $M, N, E, C$ lie on a circle. Let $M N$ meet $k_{1}$ again at $Z$. If $M^{\prime}$ is any point on the common tangent at $M$, then $\angle M C Z=\angle M^{\prime} M Z=\angle M^{\prime} M N=\angle M A N$ (as oriented angles), implying that $C Z \| A N$. It follows that $\angle A C E=$ $\angle A N M=\angle C Z M$. Hence $C E$ is tangent to $k_{1}$ and analogously to $k_{2}$. In the main problem, let us define $E$ and $F$ respectively as intersections of $N A$ and $N B$ with $\Omega_{2}$. Then applying Lemma 2 we get that $C E$ and $D F$ are the common tangents of $\Omega_{1}$ and $\Omega_{2}$. If the circles have the same radii, the result trivially holds. Otherwise, let $G$ be the intersection of $C E$ and $D F$. Let $O_{1}$ and $O_{2}$ be the centers of $\Omega_{1}$ and $\Omega_{2}$. Since $O_{1} D=O_{1} C$ and $\angle O_{1} D G=\angle O_{1} C G=90^{\circ}$, it follows that $O_{1}$ is the midpoint of the shorter arc of the circumcircle of $\triangle C D G$. The center $O_{2}$ is located on the bisector of $\angle C G D$, since $\Omega_{2}$ ![](https://cdn.mathpix.com/cropped/2024_11_18_8e985d6b9c83aa3e9d0eg-660.jpg?height=412&width=529&top_left_y=1000&top_left_x=813) touches both $G C$ and $G D$. However, it also sits on $\Omega_{1}$, and using Lemma 1 we obtain that $O_{2}$ is either at the incenter or at the excenter of $\triangle C D G$ opposite $G$. Hence, $\Omega_{2}$ is either the incircle or the excircle of $C D G$ and thus in both cases touches $C D$. Second solution. Let $O$ be the center of $\Gamma$, and $r, r_{1}, r_{2}$ the radii of $\Gamma, \Gamma_{1}, \Gamma_{2}$. It suffices to show that the distance $d\left(O_{2}, C D\right)$ is equal to $r_{2}$. The homothety with center $M$ and ratio $r / r_{1}$ takes $\Gamma_{1}, C, D$ into $\Gamma, A, B$, respectively; hence $C D \| A B$ and $d(C, A B)=\frac{r-r_{1}}{r} d(M, A B)$. Let $O_{1} O_{2}$ meet $X Y$ at $R$. Then $d\left(O_{2}, C D\right)=O_{2} R+\frac{r-r_{1}}{r} d(M, A B)$, i.e.,  $$ d\left(O_{2}, C D\right)=O_{2} R+\frac{r-r_{1}}{r}\left[O_{1} O_{2}-O_{2} R+r_{1} \cos \angle O O_{1} O_{2}\right] $$  since $O, O_{1}$, and $M$ are collinear. We have $O_{1} X=O_{1} O_{2}=r_{1}, O O_{1}=$ $r-r_{1}, O O_{2}=r-r_{2}$, and $O_{2} X=r_{2}$. Using the cosine law in the triangles $O O_{1} O_{2}$ and $X O_{1} O_{2}$, we obtain that $\cos \angle O O_{1} O_{2}=\frac{2 r_{1}^{2}-2 r r_{1}+2 r r_{2}-r_{2}^{2}}{2 r_{1}\left(r-r_{1}\right)}$ and $O_{2} R=\frac{r_{2}^{2}}{2 r_{1}}$. Substituting these values in (1) we get $d\left(O_{2}, C D\right)=r_{2}$.


13. G7 (ARM) The point $M$ inside the convex quadrilateral $A B C D$ is such that $M A=M C, \angle A M B=\angle M A D+\angle M C D, \angle C M D=\angle M C B+\angle M A B$. Prove that $A B \cdot C M=B C \cdot M D$ and $B M \cdot A D=M A \cdot C D$.

Solution: 13. Let us construct a convex quadrilateral $P Q R S$ and an interior point $T$ such that $\triangle P T Q \cong \triangle A M B, \triangle Q T R \sim \triangle A M D$, and $\triangle P T S \sim \triangle C M D$. We then have $T S=\frac{M D \cdot P T}{M C}=M D$ and $\frac{T R}{T S}=\frac{T R \cdot T Q \cdot T P}{T Q \cdot T P \cdot T S}=\frac{M D \cdot M B \cdot M C}{M A \cdot M A \cdot M D}=$ $\frac{M B}{M C}$ (using $M A=M C$ ). We also have $\angle S T R=\angle B M C$ and therefore $\triangle R T S \sim \triangle B M C$. Now the relations between angles become  $$ \angle T P S+\angle T Q R=\angle P T Q \quad \text { and } \quad \angle T P Q+\angle T S R=\angle P T S $$  implying that $P Q \| R S$ and $Q R \| P S$. Hence $P Q R S$ is a parallelogram and hence $A B=P Q=R S$ and $Q R=P S$. It follows that $\frac{B C}{M C}=\frac{R S}{T S}=$ $\frac{A B}{M D} \Rightarrow A B \cdot C M=B C \cdot M D$ and $\frac{A D \cdot B M}{A M}=\frac{A D \cdot Q T}{A M}=Q R=P S=$ $\frac{C D \cdot T S}{M D}=C D \Rightarrow B M \cdot A D=M A \cdot C D$.


14. G8 (RUS) Points $A, B, C$ divide the circumcircle $\Omega$ of the triangle $A B C$ into three arcs. Let $X$ be a variable point on the $\operatorname{arc} A B$, and let $O_{1}, O_{2}$ be the incenters of the triangles $C A X$ and $C B X$. Prove that the circumcircle of the triangle $X O_{1} O_{2}$ intersects $\Omega$ in a fixed point.

Solution: 14. We first introduce the same lemma as in problem 12 and state it here without proof. Lemma. Let $A B C$ be a triangle and $I$ the center of its incircle. Let $M$ be the center of the $\operatorname{arc} \widehat{B C}$ of the circumcircle not containing $A$. Then $M B=M C=M I$. Let the circle $X O_{1} O_{2}$ intersect the circle $\Omega$ again at point $T$. Let $M$ and $N$ be respectively the midpoints of $\operatorname{arcs} \widehat{B C}$ and $\widehat{A C}$, and let $P$ be the intersection of $\Omega$ and the line through $C$ parallel to $M N$. Then the lemma gives $M P=N C=N I=N O_{1}$ and $N P=M C=$ $M I=M O_{2}$. Since $O_{1}$ and $O_{2}$ lie on $X N$ and $X M$ respectively, we have $\angle N T M=\angle N X M=\angle O_{1} X O_{2}=\angle O_{1} T O_{2}$ and hence $\angle N T O_{1}=$ $\angle M T O_{2}$. Moreover, $\angle T N O_{1}=\angle T N X=\angle T M O_{2}$, from which it follows that $\triangle O_{1} N T \sim \triangle O_{2} M T$. Thus $\frac{N T}{M P}=\frac{N T}{N O_{1}}=\frac{M T}{M O_{2}}=\frac{M T}{N P} \Rightarrow$ $M P \cdot M T=N P \cdot N T \Rightarrow S_{M P T}=S_{N P T}$. It follows that $T P$ bisects the segment $M N$, and hence it passes through $I$. We conclude that $T$ belongs to the line $P I$ and does not depend on $X$. Remark. An alternative approach is to apply an inversion at point $C$. Points $O_{1}$ and $O_{2}$ become excenters of $\triangle A X C$ and $\triangle B X C$, and $T$ becomes the projection of $I_{c}$ onto $A B$.


15. A1 (POL) ${ }^{\mathrm{IMO} 2}$ Let $n \geq 2$ be a fixed integer. Find the least constant $C$ such that the inequality  $$ \sum_{i<j} x_{i} x_{j}\left(x_{i}^{2}+x_{j}^{2}\right) \leq C\left(\sum_{i} x_{i}\right)^{4} $$  holds for every $x_{1}, \ldots, x_{n} \geq 0$ (the sum on the left consists of $\binom{n}{2}$ summands). For this constant $C$, characterize the instances of equality.

Solution: 15. For all $x_{i}=0$ any $C$ will do, so we may assume the contrary. Since the equation is symmetric and homogeneous, we may assume $\sum_{i} x_{i}=1$. The equation now becomes $F\left(x_{1}, x_{2}, \ldots, x_{n}\right)=\sum_{i<j} x_{i} x_{j}\left(x_{i}^{2}+x_{j}^{2}\right)=$ $\sum_{i} x_{i}^{2} \sum_{j \neq i} x_{j}=\sum_{i} x_{i}^{3}\left(1-x_{i}\right)=\sum_{i} f\left(x_{i}\right) \leq C$, where we define $f(x)=$ $x^{3}-x^{4}$. We note that for $x, y \geq 0$ and $x+y \leq 2 / 3$,  $$ f(x+y)+f(0)-f(x)-f(y)=3 x y(x+y)\left(\frac{2}{3}-x-y\right) \geq 0 $$  We note that if at least three elements of $\left\{x_{1}, x_{2}, \ldots, x_{n}\right\}$ are nonzero the condition of (1) always holds for the two smallest ones. Hence, applying (1) repeatedly, we obtain $F\left(x_{1}, x_{2}, \ldots, x_{n}\right) \leq F(a, 1-a, 0, \ldots, 0)=\frac{1}{2}(2 a(1-$ a)) $(1-2 a(1-a)) \leq \frac{1}{8}=F\left(\frac{1}{2}, \frac{1}{2}, 0, \ldots, 0\right)$. Thus we have $C=\frac{1}{8}$ (for all $n$ ), and equality holds only when two $x_{i}$ are equal and the remaining ones are 0 . Second solution. Let $M=x_{1}^{2}+x_{2}^{2}+\cdots+x_{n}^{2}$. Using $a b \leq(a+2 b)^{2} / 8$ we have  $$ \begin{aligned} \sum_{1 \leq i<j \leq n} x_{i} x_{j}\left(x_{i}^{2}+x_{j}^{2}\right) & \leq M \sum_{i<j} x_{i} x_{j} \\ & \leq \frac{1}{8}\left(M+2 \sum_{i<j} x_{i} x_{j}\right)^{2}=\frac{1}{8}\left(\sum_{i=1}^{n} x_{i}\right)^{4} \end{aligned} $$  Equality holds if and only if $M=2 \sum_{i<j} x_{i} x_{j}$ and $x_{i} x_{j}\left(x_{i}^{2}+x_{j}^{2}\right)=M x_{i} x_{j}$ for all $i<j$, which holds if and only if $n-2$ of the $x_{i}$ are zero and the remaining two are equal. Remark. Problems (SL90-26) and (SL91-27) are very similar.


16. A2 (RUS) The numbers from 1 to $n^{2}$ are randomly arranged in the cells of a $n \times n$ square ( $n \geq 2$ ). For any pair of numbers situated in the same row or in the same column, the ratio of the greater number to the smaller one is calculated. Let us call the characteristic of the arrangement the smallest of these $n^{2}(n-1)$ fractions. What is the highest possible value of the characteristic?

Solution: 16. Let $C(A)$ denote the characteristic of an arrangement $A$. We shall prove that $\max C(A)=\frac{n+1}{n}$. Let us prove first $C(A) \leq \frac{n+1}{n}$ for all $A$. Among elements $\left\{n^{2}-n, n^{2}-\right.$ $\left.n+1, \ldots, n^{2}\right\}$, by the pigeonhole principle, in at least one row and at least one column there exist two elements, and hence one pair in the same row or column that is not $\left(n^{2}-n, n^{2}\right)$. Hence  $$ C(A) \leq \max \left\{\frac{n^{2}}{n^{2}-n+1}, \frac{n^{2}-1}{n^{2}-n}\right\}=\frac{n^{2}-1}{n^{2}-n}=\frac{n+1}{n} . $$  We now consider the following arrangement:  $$ a_{i j}= \begin{cases}i+n(j-i-1) & \text { if } i<j \\ i+n(n-i+j-1) & \text { if } i \geq j\end{cases} $$  We claim that $C(a)=\frac{n+1}{n}$. Indeed, in this arrangement no two numbers in the same row or column differ by less than $n-1$, and in addition, $n^{2}$ and $n^{2}-n+1$ are in different rows and columns, and hence  $$ C(A) \geq \frac{n^{2}-1}{n^{2}-n}=\frac{n+1}{n} $$


17. A3 (FIN) A game is played by $n$ girls $(n \geq 2)$, everybody having a ball. Each of the $\binom{n}{2}$ pairs of players, in an arbitrary order, exchange the balls they have at that moment. The game is called nice if at the end nobody has her own ball, and it is called tiresome if at the end everybody has her initial ball. Determine the values of $n$ for which there exists a nice game and those for which there exists a tiresome game.

Solution: 17. A game is determined by the ordering $t_{1}, \ldots, t_{N}$ of the $N=\binom{n}{2}$ transpositions $(i, j)$ of the set $\{1,2, \ldots, n\}$. The game is nice if the permutation $P=t_{N} t_{N-1} \ldots t_{1}$ has no fixed point, and tiresome if $P$ is the identity (denoted by $I$ ). Recall that every permutation can be written as a composition of disjoint cycles. We claim that there exists a nice game if and only if $n \neq 3$. For $n=2, P_{2}=t_{1}=(1,2)$ is obviously nice. For $n=3$ each game has the form $P=(b, c)(a, c)(a, b)=(a, c)$ for an appropriate notation of the players, which cannot be nice. Now for $n \geq 4$ we define $P_{n}=(1,2)(1,3)(2,3) \cdots(1, n)(2, n) \cdots(n-1, n)$. We obtain inductively that $P_{n}=P_{n-1}(1, n, n-1, \ldots, 2)=(1, n)(2, n-1) \cdots(i, n+1-i) \cdots$ is nice for all even $n$. Also, if $n=2 k+1$ is odd, then $Q_{n}=P_{n-1}(1, n)(2, n) \cdots(k, n)(n-1, n)(n-$ $2, n) \cdots(k+1, n)$ maps $i$ to $n+1-i$ for $i \leq k$, to $n-1-i$ for $k+1 \leq$ $i \leq 2 k-1$, and to $3 k+1-i$ if $i \in\{2 k, 2 k+1\}$. Hence $Q_{n}$ is nice. This justifies our claim. Now we prove that a tiresome game exists if and only if $n \equiv 0,1(\bmod 4)$. Evidently every transposition changes the sign of the permutation. Thus the sign of $P$ is $(-1)^{\binom{n}{2}}$ and for $P$ to be the identity we must have 2 $\binom{n}{2} \Rightarrow n \equiv 0,1(\bmod 4)$. Let us now construct tiresome games for the allowed $n$. For $n=4 k$ we divide the girls into groups of 4 . In each group we perform the following game: $(3,4)(1,3)(2,4)(2,3)(1,4)(1,2)=I$. On the other hand, among two different groups (call them $\{1,2,3,4\}$ and $\{5,6,7,8\}$ ) we perform  $$ \begin{aligned} & (4,7)(3,7)(4,6)(1,6)(2,8)(3,8)(2,7)(2,6) \\ & (4,5)(4,8)(1,7)(1,8)(3,5)(3,6)(2,5)(1,5)=I \end{aligned} $$  For $n=4 k+1$ we divide into groups of four as before, with one girl remaining. Every time a group (denoted $\{1,2,3,4\}$ ) is to play a game the remaining girl (denoted 5 ) joins in, and they play  $$ (3,5)(3,4)(4,5)(1,3)(2,4)(2,3)(1,4)(1,5)(1,2)(2,5)=I \text {. } $$  This completes the proof.


18. A4 (BLR) Prove that the set of positive integers cannot be partitioned into three nonempty subsets such that for any two integers $x, y$ taken from two different subsets, the number $x^{2}-x y+y^{2}$ belongs to the third subset.

Solution: 18. Define $f(x, y)=x^{2}-x y+y^{2}$. Let us assume that three such sets $A, B$, and $C$ do exist and that w.l.o.g. $1, b$, and $c(c>b)$ are respectively their smallest elements. Lemma 1. Numbers $x, y$, and $x+y$ cannot belong to three different sets. Proof. The number $f(x, x+y)=f(y, x+y)$ must belong to both the set containing $y$ and the set containing $x$, a contradiction. Lemma 2. The subset $C$ contains a multiple of $b$. Moreover, if $k b$ is the smallest such multiple, then $(k-1) b \in B$ and $(k-1) b+1, k b+1 \in A$. Proof. Let $r$ be the residue of $c$ modulo $b$. If $r=0$, the first statement automatically holds. Let $0<r<b$. In that case $r \in A$, and $c-r$ is then not in $B$ according to Lemma 1. Hence $c-r \in A$ and since $b \mid c-r$, it follows that $b \mid f(c-r, b) \in C$, thus proving the first statement. It follows immediately from Lemma 1 that $(k-1) b \in B$. Now by Lemma $1,(k-1) b+1=k b-(b-1)$ must be in $A$; similarly, $k b+1=[(k-1) b+1]+b \in A$ as well. Let us show by induction that $(n k-1) b+1, n k b+1 \in A$ for all integers $n$. The inductive basis has been shown in Lemma 2. Assuming that [ $n-$ 1) $k-1] b+1 \in A$ and $(n-1) k b+1 \in A$, we get that $(n k-1) b+1=$ $((n-1) k b+1)+(k-1) b=[((n-1) k-1) b+1]+k b$ belongs to $A$ and $n k b+1=((n k-1) b+1)+b=((n-1) k b+1)+k b \Rightarrow n k b+1 \in A$. This finishes the inductive step. In particular, $f(k b, k b+1)=(k b+1) k b+1 \in A$. However, since $k b \in C, k b+1 \in A$, it follows that $f(k b, k b+1) \in B$, which is a contradiction.


19. A5 (JAP) ${ }^{\text {IMO6 }}$ Find all the functions $f: \mathbb{R} \rightarrow \mathbb{R}$ that satisfy  $$ f(x-f(y))=f(f(y))+x f(y)+f(x)-1 $$  for all $x, y \in \mathbb{R}$.

Solution: 19. Let $A=\{f(x) \mid x \in \mathbb{R}\}$ and $f(0)=c$. Plugging in $x=y=0$ we get $f(-c)=f(c)+c-1$, hence $c \neq 0$. If $x \in A$, then taking $x=f(y)$ in the original functional equation we get $f(x)=\frac{c+1}{2}-\frac{x^{2}}{2}$ for all $x \in A$. We now show that $A-A=\left\{x_{1}-x_{2} \mid x_{1}, x_{2} \in A\right\}=\mathbb{R}$. Indeed, plugging in $y=0$ into the original equation gives us $f(x-c)-f(x)=c x+f(c)-1$, an expression that evidently spans all the real numbers. Thus, each $x$ can be represented as $x=x_{1}-x_{2}$, where $x_{1}, x_{2} \in A$. Plugging $x=x_{1}$ and $f(y)=x_{2}$ into the original equation gives us $f(x)=f\left(x_{1}-x_{2}\right)=f\left(x_{1}\right)+x_{1} x_{2}+f\left(x_{2}\right)-1=c-\frac{x_{1}^{2}+x_{2}^{2}}{2}+x_{1} x_{2}=c-\frac{x^{2}}{2}$. Hence we must have $c=\frac{c+1}{2}$, which gives us $c=1$. Thus $f(x)=1-\frac{x^{2}}{2}$ for all $x \in \mathbb{R}$. It is easily checked that this function satisfies the original functional equation.


2. N2 (ARM) Prove that every positive rational number can be represented in the form $\frac{a^{3}+b^{3}}{c^{3}+d^{3}}$, where $a, b, c, d$ are positive integers.

Solution: 2. We first prove that every rational number in the interval $(1,2)$ can be represented in the form $\frac{a^{3}+b^{3}}{a^{3}+d^{3}}$. Taking $b, d$ such that $b \neq d$ and $a=b+d$, we get $a^{2}-a b+b^{2}=a^{2}-a d+d^{2}$ and  $$ \frac{a^{3}+b^{3}}{a^{3}+d^{3}}=\frac{(a+b)\left(a^{2}-a b+b^{2}\right)}{(a+d)\left(a^{2}-a d+d^{2}\right)}=\frac{a+b}{a+d} . $$  For a given rational number $1<m / n<2$ we can select $a=m+n$ and $b=2 m-n$ such that along with $d=a-b$ we have $\frac{a+b}{a+d}=\frac{m}{n}$. This completes the proof of the first statement. For $m / n$ outside of the interval we can easily select a rational number $p / q$ such that $\sqrt[3]{\frac{n}{m}}<\frac{p}{q}<\sqrt[3]{\frac{2 n}{m}}$. In other words $1<\frac{p^{3} m}{q^{3} n}<2$. We now proceed to obtain $a, b$ and $d$ for $\frac{p^{3} m}{q^{3} n}$ as before, and we finally have  $$ \frac{p^{3} m}{q^{3} n}=\frac{a^{3}+b^{3}}{a^{3}+d^{3}} \Rightarrow \frac{m}{n}=\frac{(a q)^{3}+(b q)^{3}}{(a p)^{3}+(d p)^{3}} . $$  Thus we have shown that all positive rational numbers can be expressed in the form $\frac{a^{3}+b^{3}}{c^{3}+d^{3}}$.


20. A6 (SWE) For $n \geq 3$ and $a_{1} \leq a_{2} \leq \cdots \leq a_{n}$ given real numbers we have the following instructions: (1) place the numbers in some order in a circle; (2) delete one of the numbers from the circle; (3) if just two numbers are remaining in the circle, let $S$ be the sum of these two numbers. Otherwise, if there are more than two numbers in the circle, replace $\left(x_{1}, x_{2}, x_{3}, \ldots, x_{p-1}, x_{p}\right)$ with $\left(x_{1}+x_{2}, x_{2}+\right.$ $x_{3}, \ldots, x_{p-1}+x_{p}, x_{p}+x_{1}$ ). Afterwards, start again with step (2). Show that the largest sum $S$ that can result in this way is given by the formula  $$ S_{\max }=\sum_{k=2}^{n}\binom{n-2}{\left[\frac{k}{2}\right]-1} a_{k} $$

Solution: 20. We first introduce some useful notation. An arrangement around the circle will be denoted by $x=\left\{x_{1}, x_{2}, \ldots, x_{n}\right\}$, where the elements are arranged clockwise and $x_{1}$ is fixed to be the smallest number. We will call an arrangement balanced if $x_{1} \leq x_{n} \leq x_{2} \leq x_{n-1} \leq x_{3} \leq x_{n-2} \leq \cdots$ (the string of inequalities continues until all the elements are accounted for). We will denote the permutation of $x=\left\{x_{1}, x_{2}, \ldots, x_{n}\right\}$ in ascending order by $x^{\prime}=\left\{x_{1}^{\prime}, x_{2}^{\prime}, \ldots, x_{n}^{\prime}\right\}$. We will let $f_{i}(x)=\left\{f_{i}(x)_{1}, f_{i}(x)_{2}, \ldots, f_{i}(x)_{n-1}\right\}$ denote the arrangement after one iteration of the algorithm where $x_{i}$ was the deleted element. Lemma 1. If an arrangement $x$ is balanced, then $f_{1}(x)$ is also balanced. Proof. In one iteration we have $\left\{x_{1}, \ldots, x_{n}\right\} \rightarrow\left\{x_{n}+x_{2}, x_{2}+x_{3}, \ldots\right.$, $\left.x_{n-1}+x_{n}\right\}$. Since $x_{n} \leq x_{2} \leq x_{n-1} \leq x_{3} \leq x_{n-2} \leq \cdots$, it follows that $x_{n}+x_{2} \leq x_{n}+x_{n-1} \leq x_{2}+x_{3} \leq x_{n-1}+x_{n-2} \leq \cdots$, which means that $f_{1}(x)$ is balanced. We will first show by induction that $S_{\max }$ can be reached by using the balanced initial arrangement $\left\{a_{1}, a_{3}, a_{5}, \ldots, a_{6}, a_{4}, a_{2}\right\}$ and repeatedly deleting the smallest member. For $n=3$ we have $S_{3}=a_{2}+a_{3}$, in accordance with the formula. Assuming that the formula holds for a given $n$, we note that for an arrangement $x=\left\{a_{1}, a_{3}, a_{5}, \ldots, a_{6}, a_{4}, a_{2}\right\}$ the arrangement $f_{1}(x)$ is also balanced. We now apply the induction hypothesis and use that $\binom{n-2}{i}+\binom{n-2}{i-1}=\binom{n-1}{i}$ :  $$ \begin{aligned} S(x) & =S\left(f_{1}(x)\right) \\ & =\sum_{k=2}^{n-1}\binom{n-2}{[k / 2]-1}\left(a_{k}+a_{k+2}\right)+\binom{n-2}{[n / 2]-1}\left(a_{n}+a_{n+1}\right)=S_{\max } \end{aligned} $$  We now prove that every other arrangement yields a smaller value. We shall write $\left\{x_{1}, \ldots, x_{n}\right\} \leq\left\{y_{1}, \ldots, y_{n}\right\}$ whenever $x_{n}^{\prime}+x_{n-1}^{\prime}+\cdots+x_{i}^{\prime} \leq$ $y_{n}^{\prime}+y_{n-1}^{\prime}+\cdots+y_{i}^{\prime}$ holds for all $1 \leq i \leq n$. Lemma 2. Let $x$ be an arbitrary arrangement and $y$ a balanced arrangement, both of $n$ elements, such that $x \leq y$. Then it follows that $f_{i}(x) \leq f_{1}(y)$, for all $i$. Proof. For any $1 \leq j \leq n-1$ there exists $k_{j}$ such that $f_{i}(x)_{j}=x_{k_{j}}+x_{k_{j}+1}$ (assuming $k_{j}+1=1$ if $k_{j}=n-1$ ). Then we have  $$ \begin{aligned} f_{i}(x)_{n-1}+\cdots+f_{i}(x)_{n-j} & =\left(x_{k_{1}}+x_{k_{1}+1}\right)+\cdots+\left(x_{k_{j}}+x_{k_{j}+1}\right) \\ & \leq 2 x_{n}^{\prime}+\cdots+2 x_{n-i+1}^{\prime}+x_{n-i}^{\prime}+x_{n-i-1}^{\prime} \\ & =f_{1}(y)_{n-1}+\cdots+f_{1}(y)_{n-j} \end{aligned} $$  for all $j$, and hence $f_{i}(x) \leq f_{1}(y)$. An immediate consequence of Lemma 2 is $f^{n-2}(x) \leq f_{1}^{n-2}(y)$, implying $S=f^{n-2}(x)_{1}+f^{n-2}(x)_{2} \leq f_{1}^{n-2}(y)_{1}+f_{1}^{n-2}(y)_{2}=S_{\max }(y)$. Thus the proof is finished.


21. C1 (IND) Let $n \geq 1$ be an integer. A path from $(0,0)$ to $(n, n)$ in the $x y$ plane is a chain of consecutive unit moves either to the right (move denoted by $E$ ) or upwards (move denoted by $N$ ), all the moves being made inside the half-plane $x \geq y$. A step in a path is the occurrence of two consecutive moves of the form $E N$. Show that the number of paths from $(0,0)$ to $(n, n)$ that contain exactly $s$ steps $(n \geq s \geq 1)$ is  $$ \frac{1}{s}\binom{n-1}{s-1}\binom{n}{s-1} $$

Solution: 21. Let us call $f(n, s)$ the number of paths from $(0,0)$ to $(n, n)$ that contain exactly $s$ steps. Evidently, for all $n$ we have $f(n, 1)=f(2,2)=1$, in accordance with the formula. Let us thus assume inductively for a given $n>2$ that for all $s$ we have $f(n, s)=\frac{1}{s}\binom{n-1}{s-1}\binom{n}{s-1}$. We shall prove that the given formula holds also for all $f(n+1, s)$, where $s \geq 2$. We say that an $(n+1, s)$ - or $(n+1, s+1)$-path is related to a given $(n, s)$ path if it is obtained from the given path by inserting a step $E N$ between two moves or at the beginning or the end of the path. We note that by inserting the step between two moves that form a step one obtains an $(n+1, s)$-path; in all other cases one obtains an $(n+1, s+1)$-path. For each $(n, s)$-path there are exactly $2 n+1-s$ related $(n+1, s+1)$-paths, and for each $(n, s+1)$-path there are $s+1$ related $(n+1, s+1)$-paths. Also, each $(n+1, s+1)$-path is related to exactly $s+1$ different $(n, s)$ - or $(n, s+1)$-paths. Thus:  $$ \begin{aligned} (s+1) f(n+1, s+1) & =(2 n+1-s) f(n, s)+(s+1) f(n, s+1) \\ & =\frac{2 n+1-s}{s}\binom{n-1}{s-1}\binom{n}{s-1}+\binom{n-1}{s}\binom{n}{s} \\ & =\binom{n}{s}\binom{n+1}{s}, \end{aligned} $$  i.e., $f(n+1, s+1)=\frac{1}{s+1}\binom{n}{s}\binom{n+1}{s}$. This completes the proof.


22. C2 (CAN) (a) If a $5 \times n$ rectangle can be tiled using $n$ pieces like those shown in the diagram, prove that $n$ is even. ![](https://cdn.mathpix.com/cropped/2024_11_18_8e985d6b9c83aa3e9d0eg-314.jpg?height=111&width=365&top_left_y=1607&top_left_x=644) (b) Show that there are more than $2 \cdot 3^{k-1}$ ways to tile a fixed $5 \times 2 k$ rectangle ( $k \geq 3$ ) with $2 k$ pieces. (Symmetric constructions are considered to be different.)

Solution: 22. (a) Color the first, third, and fifth row red, and the remaining squares white. There in total $n$ pieces and $3 n$ red squares. Since each piece can cover at most three red squares, it follows that each piece colors exactly three red squares. Then it follows that the two white squares it covers must be on the same row; otherwise, the piece has to cover at least three. Hence, each white row can be partitioned into pairs of squares belonging to the same piece. Thus it follows that the number of white squares in a row, which is $n$, must be even. (b) Let $a_{k}$ denote the number of different tilings of a $5 \times 2 k$ rectangle. Let $b_{k}$ be the number of tilings that cannot be partitioned into two smaller tilings along a vertical line (without cutting any pieces). It is easy to see that $a_{1}=b_{1}=2, b_{2}=2, a_{2}=6=2 \cdot 3, b_{3}=4$, and subsequently, by induction, $b_{3 k} \geq 4, b_{3 k+1} \geq 2$, and $b_{3 k+2} \geq 2$. We also have $a_{k}=b_{k}+\sum_{i=1}^{k-1} b_{i} a_{k-i}$. For $k \geq 3$ we now have inductively  $$ a_{k}>2+\sum_{i=1}^{k-1} 2 a_{k-i} \geq 2 \cdot 3^{k-1}+2 a_{k-1} \geq 2 \cdot 3^{k} $$


23. C3 (GBR) A biologist watches a chameleon. The chameleon catches flies and rests after each catch. The biologist notices that: (i) the first fly is caught after a resting period of one minute; (ii) the resting period before catching the $2 m$ th fly is the same as the resting period before catching the $m$ th fly and one minute shorter than the resting period before catching the $(2 m+1)$ th fly; (iii) when the chameleon stops resting, he catches a fly instantly. (a) How many flies were caught by the chameleon before his first resting period of 9 minutes? (b) After how many minutes will the chameleon catch his 98th fly? (c) How many flies were caught by the chameleon after 1999 minutes passed?

Solution: 23. Let $r(m)$ denote the rest period before the $m$ th catch, $t(m)$ the number of minutes before the $m$ th catch, and $f(n)$ as the number of flies caught in $n$ minutes. We have $r(1)=1, r(2 m)=r(m)$, and $r(2 m+1)=f(m)+1$. We then have by induction that $r(m)$ is the number of ones in the binary representation of $m$. We also have $t(m)=\sum_{i=1}^{m} r(i)$ and $f(t(m))=m$. From the recursive relations for $r$ we easily derive $t(2 m+1)=2 t(m)+m+1$ and consequently $t(2 m)=2 t(m)+m-r(m)$. We then have, by induction on $p, t\left(2^{p} m\right)=2^{p} t(m)+p \cdot m \cdot 2^{p-1}-\left(2^{p}-1\right) r(m)$. (a) We must find the smallest number $m$ such that $r(m+1)=9$. The smallest number with nine binary digits is $\overline{111111111}_{2}=511$; hence the required $m$ is 510 . (b) We must calculate $t(98)$. Using the recursive formulas we have $t(98)=$ $2 t(49)+49-r(49), t(49)=2 t(24)+25$, and $t(24)=8 t(3)+36-7 r(3)$. Since we have $t(3)=4, r(3)=2$ and $r(49)=r\left(\overline{110001}_{2}\right)=3$, it follows $t(24)=54 \Rightarrow t(49)=133 \Rightarrow t(98)=312$. (c) We must find $m_{c}$ such that $t\left(m_{c}\right) \leq 1999<t\left(m_{c}+1\right)$. One can estimate where this occurs using the formula $t\left(2^{p}\left(2^{q}-1\right)\right)=(p+$ $q) 2^{p+q-1}-p 2^{p-1}-q 2^{p}+q$, provable from the recursive relations. It suffices to note that $t(462)=1993$ and $t(463)=2000$; hence $m_{c}=462$.


24. C4 (GBR) Let $A$ be a set of $N$ residues $\left(\bmod N^{2}\right)$. Prove that there exists a set $B$ of $N$ residues $\left(\bmod N^{2}\right)$ such that the set $A+B=\{a+b \mid$ $a \in A, b \in B\}$ contains at least half of all residues $\left(\bmod N^{2}\right)$.

Solution: 24. Let $S=\left\{0,1, \ldots, N^{2}-1\right\}$ be the group of residues (with respect to addition modulo $N^{2}$ ) and $A$ an $n$-element subset. We will use $|X|$ to denote the number of elements of a subset $X$ of $S$, and $\bar{X}$ to refer to the complement of $X$ in $S$. For $i \in S$ we also define $A_{i}=\{a+i \mid a \in A\}$. Our task is to select $0 \leq i_{1}<\cdots<i_{N} \leq N^{2}-1$ such that $\left|\bigcup_{j=1}^{N} A_{i_{j}}\right| \geq \frac{1}{2}|S|$. Each $x \in S$ appears in exactly $N$ sets $A_{i}$. We have  $$ \begin{aligned} \sum_{i_{1}<\cdots<i_{N}}\left|\bigcap_{j=1}^{N} \bar{A}_{i_{j}}\right| & =\sum_{i_{1}<\cdots<i_{N}}\left|\left\{x \in S \mid x \notin A_{i_{1}}, \ldots, A_{i_{N}}\right\}\right| \\ & =\sum_{x \in S}\left|\left\{i_{1}<\cdots<i_{N} \mid x \notin A_{i_{1}}, \ldots, A_{i_{N}}\right\}\right| \\ & =\sum_{x \in S}\binom{N^{2}-N}{N}=\binom{N^{2}-N}{N}|S| . \end{aligned} $$  Hence  $$ \begin{aligned} \sum_{i_{1}<\cdots<i_{N}}\left|\bigcup_{j=1}^{N} A_{i_{j}}\right| & =\sum_{i_{1}<\cdots<i_{N}}\left(|S|-\left|\bigcap_{j=1}^{N} \bar{A}_{i_{j}}\right|\right) \\ & =\left(\binom{N^{2}}{N}-\binom{N^{2}-N}{N}\right)|S| . \end{aligned} $$  Thus, by the pigeonhole principle, one can choose $i_{1}<\cdots<i_{N}$ such that $\left|\bigcup_{j=1}^{N} A_{i_{j}}\right| \geq\left(1-\binom{N^{2}-N}{N} /\binom{N^{2}}{N}\right)|S|$. Since $\binom{N^{2}}{N} /\binom{N^{2}-N}{N} \geq\left(\frac{N^{2}}{N^{2}-N}\right)^{N}$ $=\left(1+\frac{1}{N-1}\right)^{N}>e>2$, it follows that $\left|\bigcup_{j=1}^{N} A_{i_{j}}\right| \geq \frac{1}{2}|S|$; hence the chosen $i_{1}<\cdots<i_{N}$ are indeed the elements of $B$ that satisfy the conditions of the problem.


25. C5 (BLR) ${ }^{\mathrm{IMO} 3}$ Let $n$ be an even positive integer. We say that two different cells of an $n \times n$ board are neighboring if they have a common side. Find the minimal number of cells on the $n \times n$ board that must be marked so that every cell (marked or not marked) has a marked neighboring cell.

Solution: 25 . Let $n=2 k$. Color the cells neighboring the edge of the board black. Then color the cells neighboring the black cells white. Then in alternation color the still uncolored cells neighboring the white or black cells on the boundary the opposite color ![](https://cdn.mathpix.com/cropped/2024_11_18_8e985d6b9c83aa3e9d0eg-667.jpg?height=308&width=311&top_left_y=1188&top_left_x=924) and repeat until all cells are colored. We call the cells colored the same color in each such iteration a "frame." In the color scheme described, each cell (white or black) neighbors exactly two black cells. The number of black cells is $2 k(k+1)$, and hence we need to mark at least $k(k+1)$ cells. On the other hand, going along each black-colored frame, we can alternately mark two consecutive cells and then not mark two consecutive cells. Every cell on the black frame will have one marked neighbor. One can arrange these sequences on two consecutive black frames such that each cell in the white frame in between has exactly one neighbor. Hence, starting from a sequence on the largest frame we obtain a marking that contains exactly half of all the black cells, i.e., $k(k+1)$ and neighbors every cell. It follows that the desired minimal number of markings is $k(k+1)$. Remark. For $n=4 k-1$ and $n=4 k+1$ one can perform similar markings to obtain minimal numbers $4 k^{2}-1$ and $(2 k+1)^{2}$, respectively.


26. C6 (GBR) Suppose that every integer has been given one of the colors red, blue, green, yellow. Let $x$ and $y$ be odd integers such that $|x| \neq|y|$. Show that there are two integers of the same color whose difference has one of the following values: $x, y, x+y, x-y$.

Solution: 26. We denote colors by capital initial letters. Let us suppose that there exists a coloring $f: \mathbb{Z} \rightarrow\{R, G, B, Y\}$ such that for any $a \in \mathbb{Z}$ we have $f\{a, a+$ $x, a+y, a+x+y\}=\{R, G, B, Y\}$. We now define a coloring of an integer lattice $g: \mathbb{Z} \times \mathbb{Z} \rightarrow\{R, G, B, Y\}$ by the rule $g(i, j)=f(x i+y j)$. It follows that every unit square in $g$ must have its vertices colored by four different colors. If there is a row or column with period 2 , then applying the condition to adjacent unit squares, we get (by induction) that all rows or columns, respectively, have period 2 . On the other hand, taking a row to be not of period 2, i.e., containing a sequence of three distinct colors, for example $G R Y$, we get that the next row must contain in these columns $Y B G$, and the following $G R Y$, and so on. It would follow that a column in this case must have period 2. A similar conclusion holds if we start with an aperiodic column. Hence either all rows or all columns must have period 2. Let us assume w.l.o.g. that all rows have a period of 2. Assuming w.l.o.g. $\{g(0,0), g(1,0)\}=\{G, B\}$, we get that the even rows are painted with $\{G, B\}$ and odd with $\{Y, R\}$. Since $x$ is odd, it follows that $g(y, 0)$ and $g(0, x)$ are of different color. However, since $g(y, 0)=f(x y)=g(0, x)$, this is a contradiction. Hence the statement of the problem holds.


27. C7 (IRE) Let $p>3$ be a prime number. For each nonempty subset $T$ of $\{0,1,2,3, \ldots, p-1\}$ let $E(T)$ be the set of all $(p-1)$-tuples $\left(x_{1}, \ldots, x_{p-1}\right)$, where each $x_{i} \in T$ and $x_{1}+2 x_{2}+\cdots+(p-1) x_{p-1}$ is divisible by $p$ and let $|E(T)|$ denote the number of elements in $E(T)$. Prove that  $$ |E(\{0,1,3\})| \geq|E(\{0,1,2\})|, $$  with equality if and only if $p=5$.

Solution: 27. Denote $A=\{0,1,2\}$ and $B=\{0,1,3\}$. Let $f_{T}(x)=\sum_{a \in T} x^{a}$. Then define $F_{T}(x)=f_{T}(x) f_{T}\left(x^{2}\right) \cdots f_{T}\left(x^{p-1}\right)$. We can write $F_{T}(x)=\sum_{i=0}^{p(p-1)} a_{i} x^{i}$, where $a_{i}$ is the number of ways to select an array $\left\{x_{1}, \ldots, x_{p-1}\right\}$ where $x_{i} \in T$ for all $i$ and $x_{1}+2 x_{2}+\cdots+(p-1) x_{p-1}=i$. Let $w=\cos (2 \pi / p)+$ $i \sin (2 \pi / p)$, a $p$ th root of unity. Noting that  $$ 1+w^{j}+w^{2 j}+\cdots+w^{(p-1) j}=\left\{\begin{array}{c} p, p \mid j, \\ 0, p \nmid j, \end{array}\right. $$  it follows that $F_{T}(1)+F_{T}(w)+\cdots+F_{T}\left(w^{p-1}\right)=p E(T)$. Since $|A|=|B|=3$, it follows that $F_{A}(1)=F_{B}(1)=3^{p-1}$. We also have for $p \nmid i, j$ that $F_{T}\left(w^{i}\right)=F_{T}(w)$. Finally, we have  $$ F_{A}(w)=\prod_{i=1}^{p-1}\left(1+w^{i}+w^{2 i}\right)=\prod_{i=1}^{p-1} \frac{1-w^{3 i}}{1-w^{i}}=1 $$  Hence, combining these results, we obtain  $$ E(A)=\frac{3^{p-1}+p-1}{p} \text { and } E(B)=\frac{3^{p-1}+(p-1) F_{B}(w)}{p} $$  It remains to demonstrate that $F_{B}(w) \geq 1$ for all $p$ and that equality holds only for $p=5$. Since $E(B)$ is an integer, it follows that $F_{B}(w)$ is an integer and $F_{B}(w) \equiv 1(\bmod p)$. Since $f_{B}\left(w^{p-i}\right)=\overline{f_{B}\left(w^{i}\right)}$, it follows that $F_{B}(w)=\left|f_{B}(w)\right|^{2}\left|f_{B}\left(w^{2}\right)\right|^{2} \cdots\left|f_{B}\left(w^{(p-1) / 2}\right)\right|^{2}>0$. Hence $F_{B}(w) \geq 1$.  It remains to show that $F_{B}(w)=1$ if and only if $p=5$. We have the formula $(x-w)\left(x-w^{2}\right) \cdots\left(x-w^{p-1}\right)=x^{p-1}+x^{p-2}+\cdots+x+1=\frac{x^{p}-1}{x-1}$. Let $f_{B}(x)=x^{3}+x+1=(x-\lambda)(x-\mu)(x-\nu)$, where $\lambda$, $\mu$, and $\nu$ are the three zeros of the polynomial $f_{B}(x)$. It follows that $F_{B}(w)=\left(\frac{\lambda^{p}-1}{\lambda-1}\right)\left(\frac{\mu^{p}-1}{\mu-1}\right)\left(\frac{\nu^{p}-1}{\nu-1}\right)=-\frac{1}{3}\left(\lambda^{p}-1\right)\left(\mu^{p}-1\right)\left(\nu^{p}-1\right)$, since $(\lambda-1)(\mu-1)(\nu-1)=-f_{B}(1)=-3$. We also have $\lambda+\mu+\nu=0$, $\lambda \mu \nu=-1, \lambda \mu+\lambda \nu+\mu \nu=1$, and $\lambda^{2}+\mu^{2}+\nu^{2}=(\lambda+\mu+\nu)^{2}-2(\lambda \mu+$ $\lambda \nu+\mu \nu)=-2$. By induction (using that $\left(\lambda^{r}+\mu^{r}+\nu^{r}\right)+\left(\lambda^{r-2}+\mu^{r-2}+\right.$ $\left.\nu^{r-2}\right)+\left(\lambda^{r-3}+\mu^{r-3}+\nu^{r-3}\right)=0$ ), it follows that $\lambda^{r}+\mu^{r}+\nu^{r}$ is an integer for all $r \in \mathbb{N}$. Let us assume $F_{B}(x)=1$. It follows that $\left(\lambda^{p}-1\right)\left(\mu^{p}-1\right)\left(\nu^{p}-1\right)=-3$. Hence $\lambda^{p}, \mu^{p}, \nu^{p}$ are roots of the polynomial $p(x)=x^{3}-q x^{2}+(1+q) x+1$, where $q=\lambda^{p}+\mu^{p}+\nu^{p}$. Since $f_{B}(x)$ is an increasing function in real numbers, it follows that it has only one real root (w.l.o.g.) $\lambda$, the other two roots being complex conjugates. From $f_{B}(-1)<0<f_{B}(-1 / 2)$ it follows that $-1<\lambda<-1 / 2$. It also follows that $\lambda^{p}$ is the $x$ coordinate of the intersection of functions $y=x^{3}+x+1$ and $y=q\left(x^{2}-x\right)$. Since $\lambda<\lambda^{p}<0$, it follows that $q>0$; otherwise, $q\left(x^{2}-x\right)$ intersects $x^{3}+x+1$ at a value smaller than $\lambda$. Additionally, as $p$ increases, $\lambda^{p}$ approaches 0 , and hence $q$ must increase. For $p=5$ we have $1+w+w^{3}=-w^{2}\left(1+w^{2}\right)$ and hence $G(w)=\prod_{i=1}^{p-1}(1+$ $\left.w^{2 j}\right)=1$. For a zero of $f_{B}(x)$ we have $x^{5}=-x^{3}-x^{2}=-x^{2}+x+1$ and hence $q=\lambda^{5}+\mu^{5}+\nu^{5}=-\left(\lambda^{2}+\mu^{2}+\nu^{2}\right)+(\lambda+\mu+\nu)+3=5$. For $p>5$ we also have $q \geq 6$. Assuming again $F_{B}(x)=1$ and defining $p(x)$ as before, we have $p(-1)<0, p(0)>0, p(2)<0$, and $p(x)>0$ for a sufficiently large $x>2$. It follows that $p(x)$ must have three distinct real roots. However, since $\mu^{p}, \nu^{p} \in \mathbb{R} \Rightarrow \nu^{p}=\overline{\mu^{p}}=\mu^{p}$, it follows that $p(x)$ has at most two real roots, which is a contradiction. Hence, it follows that $F_{B}(x)>1$ for $p>5$ and thus $E(A) \leq E(B)$, where equality holds only for $p=5$.


3. N3 (RUS) Prove that there exist two strictly increasing sequences $\left(a_{n}\right)$ and $\left(b_{n}\right)$ such that $a_{n}\left(a_{n}+1\right)$ divides $b_{n}^{2}+1$ for every natural number $n$.

Solution: 3. We first prove the following lemma.  Lemma. For $d, c \in \mathbb{N}$ and $d^{2} \mid c^{2}+1$ there exists $b \in \mathbb{N}$ such that $d^{2}\left(d^{2}+1\right) \mid b^{2}+1$. Proof. It is enough to set $b=c+d^{2} c-d^{3}=c+d^{2}(c-d)$.  Using the lemma it suffices to find increasing sequences $d_{n}$ and $c_{n}$ such that $c_{n}-d_{n}$ is an increasing sequence and $d_{n}^{2} \mid c_{n}^{2}+1$. We then obtain the desired sequences $a_{n}$ and $b_{n}$ from $a_{n}=d_{n}^{2}$ and $b_{n}=c_{n}+d_{n}^{2}\left(c_{n}-d_{n}\right)$. It is easy to check that $d_{n}=2^{2 n}+1$ and $c_{n}=2^{n d_{n}}$ satisfy the required conditions. Hence we have demonstrated the existence of increasing sequences $a_{n}$ and $b_{n}$ such that $a_{n}\left(a_{n}+1\right) \mid b_{n}^{2}+1$. Remark. There are many solutions to this problem. For example, it is sufficient to prove that the Pell-type equation $5 a_{n}\left(a_{n}+1\right)=b_{n}^{2}+1$ has an infinity of solutions in positive integers. Alternatively, one can show that $a_{n}\left(a_{n}+1\right)$ can be represented as a sum of two coprime squares for infinitely many $a_{n}$, which implies the existence of $b_{n}$.


4. N4 (FRA) Denote by $S$ the set of all primes $p$ such that the decimal representation of $1 / p$ has its fundamental period divisible by 3 . For every $p \in S$ such that $1 / p$ has its fundamental period $3 r$ one may write $1 / p=$ $0 . a_{1} a_{2} \ldots a_{3 r} a_{1} a_{2} \ldots a_{3 r} \ldots$, where $r=r(p)$; for every $p \in S$ and every integer $k \geq 1$ define $f(k, p)$ by  $$ f(k, p)=a_{k}+a_{k+r(p)}+a_{k+2 r(p)} $$  (a) Prove that $S$ is infinite. (b) Find the highest value of $f(k, p)$ for $k \geq 1$ and $p \in S$.

Solution: 4. (a) The fundamental period of $p$ is the smallest integer $d(p)$ such that $p \mid 10^{d(p)}-1$. Let $s$ be an arbitrary prime and set $N_{s}=10^{2 s}+10^{s}+1$. In that case $N_{s} \equiv 3(\bmod 9)$. Let $p_{s} \neq 37$ be a prime dividing $N_{s} / 3$. Clearly $p_{s} \neq 3$. We claim that such a prime exists and that $3 \mid d\left(p_{s}\right)$. The prime $p_{s}$ exists, since otherwise $N_{s}$ could be written in the form $N_{s}=3 \cdot 37^{k} \equiv$ $3(\bmod 4)$, while on the other hand for $s>1$ we have $N_{s} \equiv 1(\bmod 4)$. Now we prove $3 \mid d\left(p_{s}\right)$. We have $p_{s}\left|N_{s}\right| 10^{3 s}-1$ and hence $d\left(p_{s}\right) \mid 3 s$. We cannot have $d\left(p_{s}\right) \mid s$, for otherwise $p_{s}\left|10^{s}-1 \Rightarrow p_{s}\right|\left(10^{2 s}+\right.$ $\left.10^{s}+1,10^{s}-1\right)=3$; and we cannot have $d\left(p_{s}\right) \mid 3$, for otherwise $p_{s} \mid 10^{3}-1=999=3^{3} \cdot 37$, both of which contradict $p_{s} \neq 3,37$. It follows that $d\left(p_{s}\right)=3 s$. Hence for every prime $s$ there exists a prime $p_{s}$ such that $d\left(p_{s}\right)=3 s$. It follows that the cardinality of $S$ is infinite. (b) Let $r=r(s)$ be the fundamental period of $p \in S$. Then $p \mid 10^{3 r}-1$, $p \nmid 10^{r}-1 \Rightarrow p \mid 10^{2 r}+10^{r}+1$. Let $x_{j}=\frac{10^{j-1}}{p}$ and $y_{j}=\left\{x_{j}\right\}=$ $0 . a_{j} a_{j+1} a_{j+2} \ldots$. Then $a_{j}<10 y_{j}$, and hence  $$ f(k, p)=a_{k}+a_{k+r}+a_{k+2 r}<10\left(y_{k}+y_{k+r}+y_{k+2 r}\right) . $$  We note that $x_{k}+x_{k+s(p)}+x_{k+2 s(p)}=\frac{10^{k-1} N_{p}}{p}$ is an integer, from which it follows that $y_{k}+y_{k+s(p)}+y_{k+2 s(p)} \in \mathbb{N}$. Hence $y_{k}+y_{k+s(p)}+$ $y_{k+2 s(p)} \leq 2$. It follows that $f(k, p)<20$. We note that $f(2,7)=$ $4+8+7=19$. Hence 19 is the greatest possible value of $f(k, p)$.


5. N5 (ARM) Let $n, k$ be positive integers such that $n$ is not divisible by 3 and $k \geq n$. Prove that there exists a positive integer $m$ that is divisible by $n$ and the sum of whose digits in decimal representation is $k$.

Solution: 5. Since one can arbitrarily add zeros at the end of $m$, which increases divisibility by 2 and 5 to an arbitrary exponent, it suffices to assume $2,5 \nmid n$. If $(n, 10)=1$, there exists an integer $w \geq 2$ such that $10^{w} \equiv 1(\bmod n)$. We also note that $10^{i w} \equiv 1(\bmod n)$ and $10^{j w+1} \equiv 10(\bmod n)$ for all integers $i$ and $j$. Let us assume that $m$ is of the form $m=\sum_{i=1}^{u} 10^{i w}+\sum_{j=1}^{v} 10^{j w+1}$ for integers $u, v \geq 0$ (where if $u$ or $v$ is 0 , the corresponding sum is 0 ). Obviously, the sum of the digits of $m$ is equal to $u+v$, and also $m \equiv u+10 v(\bmod n)$. Hence our problem reduces to finding integers $u, v \geq 0$ such that $u+v=k$ and $n \mid u+10 v=k+9 v$. Since $(n, 9)=1$, it follows that there exists some $v_{0}$ such that $0 \leq v_{0}<n \leq k$ and $9 v_{0} \equiv$ $-k(\bmod n) \Rightarrow n \mid k+9 v_{0}$. Taking this $v_{0}$ and setting $u_{0}=k-v_{0}$ we obtain the desired parameters for defining $m$.


6. N6 (BLR) Prove that for every real number $M$ there exists an infinite arithmetic progression such that: (i) each term is a positive integer and the common difference is not divisible by 10 ; (ii) the sum of the digits of each term (in decimal representation) exceeds $M$.

Solution: 6. Let $N$ be the smallest integer greater than $M$. We take the difference of the numbers in the progression to be of the form $10^{m}+1, m \in \mathbb{N}$. Hence we can take $a_{n}=a_{0}+n\left(10^{m}+1\right)=\overline{b_{s} b_{s-1} \ldots b_{0}}$ where $a_{0}$ is the initial term in the progression and $\overline{b_{s} b_{s-1} \ldots b_{0}}$ is the decimal representation of $a_{n}$. Since $2 m$ is the smallest integer $x$ such that $10^{x} \equiv 1\left(\bmod 10^{m}+1\right)$, it follows that $10^{k} \equiv 10^{l}\left(\bmod 10^{m}+1\right) \Leftrightarrow k \equiv l(\bmod 2 m)$. Hence  $$ a_{0} \equiv a_{n}=\overline{b_{s} b_{s-1} \ldots b_{0}} \equiv \sum_{i=0}^{2 m-1} c_{i} 10^{i}\left(\bmod 10^{m}+1\right), $$  where $c_{i}=b_{i}+b_{2 m+i}+b_{4 m+i}+\cdots \geq 0$ for $i=0,1, \ldots, 2 m-1$ (these $c_{i}$ also depend on $n$ ). We note that $\sum_{i=0}^{2 m-1} c_{i} 10^{i}$ is invariant modulo $10^{m}+1$ for all $n$ and that $\sum_{i=0}^{2 m-1} c_{i}=\sum_{j=0}^{s} b_{j}$ for a given $n$. Hence we must choose $a_{0}$ and $m$ such that $a_{0}$ is not congruent to any number of the form $\sum_{i=0}^{2 m-1} c_{i} 10^{i}$, where $c_{0}+c_{1}+\cdots+c_{2 m-1} \leq N\left(c_{0}, c_{1}, \ldots, c_{2 m-1} \geq 0\right)$. The number of ways to select the nonnegative integers $c_{0}, c_{1}, \ldots, c_{2 m-1}$ such that $c_{0}+c_{1}+\cdots+c_{2 m-1} \leq N$ is equal to the number of strictly increasing sequences $0 \leq c_{0}<c_{0}+c_{1}+1<c_{0}+c_{1}+c_{2}+2+\cdots<$ $c_{0}+c_{1}+\cdots+c_{2 m-1}+2 m-1 \leq N+2 m-1$, which is equal to the number of $2 m$-element subsets of $\{0,1,2, \ldots, N+2 m-1\}$, which is $\binom{N+2 m}{N}$. For sufficiently large $m$ we have $\binom{N+2 m}{N}<10^{m}$, and hence in this case one can select $a_{0}$ such that $a_{0}$ is not congruent to $\sum_{i=0}^{2 m-1} c_{i} 10^{i}$ modulo $10^{m}+1$ for any set of integers $c_{0}, c_{1}, \ldots, c_{2 m-1}$ such that $c_{0}+c_{1}+\cdots+c_{2 m-1} \leq N$. Thus we have found the desired arithmetic progression.


7. G1 (ARM) Let $A B C$ be a triangle and $M$ an interior point. Prove that  $$ \min \{M A, M B, M C\}+M A+M B+M C<A B+A C+B C . $$

Solution: 7. We use the following simple lemma.  Lemma. Suppose that $M$ is the interior point of a convex quadrilateral $A B C D$. Then it follows that $M A+M B<A D+D C+C B$. Proof. We repeatedly make use of the triangle inequality. The line $A M$, in addition to $A$, intersects the quadrilateral in a second point $N$. In that case $A M+M B<A N+N B<A D+D C+C B$. We now apply this lemma in the following way. Let $D, E$, and $F$ be median points of $B C, A C$, and $A B$. Any point $M$ in the interior of $\triangle A B C$ is contained in at least two of the three convex quadrilaterals $A B D E$, $B C E F$, and $C A F D$. Let us assume without loss of generality that $M$ is in the interior of $B C E F$ and $C A F D$. In that case we apply the lemma to obtain $A M+C M<A F+F D+D C$ and $B M+C M<C E+E F+F B$ to obtain  $$ \begin{aligned} C M+A M+B M+C M & <A F+F D+D C+C E+E F+F B \\ & =A B+A C+B C \end{aligned} $$  from which the required conclusion immediately follows.


8. G2 (JAP) A circle is called a separator for a set of five points in a plane if it passes through three of these points, it contains a fourth point in its interior, and the fifth point is outside the circle. Prove that every set of five points such that no three are collinear and no four are concyclic has exactly four separators.

Solution: 8. Let $A, B, C$, and $D$ be inverses of four of the five points, with the fifth point being the pole of the inversion. A separator through the pole transforms into a line containing two of the remaining four points such that the remaining two points are on opposite sides of the line. A separator not containing the pole transforms into a circle through three of the points with the fourth point in its interior. Let $K$ be the convex hull of $A, B, C$, and $D$. We observe two cases: (i) $K$ is a quadrilateral, for example $A B C D$. In that case the four separators are the two diagonals and two circles $A B C$ and $A D C$ if $\angle A+\angle C<180^{\circ}$, or $B A D$ and $B C D$ otherwise. The remaining six viable circles and lines are clearly not separators. (ii) $K$ is a triangle, for example $A B C$ with $D$ in its interior. In that case the separators are lines $D A, D B, D C$ and the circle $A B C$. No other lines and circles qualify. We have thus shown that any set of five points satisfying the stated conditions will have exactly four separators.


9. G3 (EST) ${ }^{\mathrm{IMO} 1}$ A set $S$ of points in space will be called completely symmetric if it has at least three elements and satisfies the following condition: For every two distinct points $A, B$ from $S$ the perpendicular bisector of the segment $A B$ is an axis of symmetry for $S$. Prove that if a completely symmetric set is finite, then it consists of the vertices of either a regular polygon, a regular tetrahedron, or a regular octahedron.

Solution: 9. Let $r_{P Q}$ denote a reflection about the planar bisector of $P Q$ with $P, Q \in S$. Let $G$ be the centroid of $S$. From $r_{P Q}(S)=S$ it follows that $r_{P Q}(G)=G$. Hence $G$ belongs to the perpendicular bisector of $P Q$ and thus $G P=G Q$. Consequently the whole of $S$ lies on a sphere $\Sigma$ centered at $G$. We note the following two cases: (a) $S$ is a subset of a plane $\pi$. In this case $S$ is included in a circle $k, G$ being its center. Hence its $n$ points form a convex polygon $A_{1} A_{2} \ldots A_{n}$. When applying $r_{A_{i} A_{i+2}}$ for some $0<i<n-1$ the point $A_{i+1}$ transforms into some point of $S$ lying on the same side of $A_{i} A_{i+1}$, which has to be $A_{i+1}$ itself. It thus follows that $A_{i} A_{i+1}=A_{i+1} A_{i+2}$ for all $0<i<n-1$ and hence $A_{1} A_{2} \ldots A_{n}$ is a regular $n$-gon. (b) The points in $S$ are not coplanar. It follows that $S$ is a polyhedron $P$ inscribed in a sphere $\Sigma$ centered at $G$. By applying the previous case to the faces of the polyhedron, it follows that all faces are regular $n$-gons. Let us take an arbitrary vertex $V$ and let $V V_{1}, V V_{2}$ and $V V_{3}$ be three consecutive edges stemming from $V\left(V, V_{1}, V_{2}\right.$, and $V_{3}$ defining two adjacent faces of $P$ ). We now look at $r_{V_{1} V_{3}}$. Since this transformation leaves the half-planes $\left[V_{1} V_{3}, V_{2}\right.$ and $\left[V_{1} V_{3}, V\right.$ invariant and since $V_{2}$ and $V$ are the only points of $P$ on the respective half-planes, it follows that $r_{V_{1} V_{3}}$ leaves $V$ and $V_{2}$ invariant. This transform also swaps $V_{1}$ and $V_{3}$. Hence, the face determined by $V V_{1} V_{2}$ is transformed by $r_{V_{1} V_{3}}$ into the face $V V_{3} V_{2}$, and thus the two faces sharing $V V_{2}$ are congruent. We conclude that all faces are congruent and similarly that vertices are endpoints of the same number of edges; hence $P$ is a regular polyhedron. Finally, we have to rule out $S$ being vertices of a cube, a dodecahedron, or an icosahedron. In all of these cases if we select two diametrically opposite points $P$ and $Q$, then $S \backslash\{P, Q\}$ is not symmetric with respect to the bisector of $P Q$, which prevents $r_{P Q}$ from being an invariant transformation of $S$. It thus follows that the only viable finite completely symmetric sets are vertices of regular $n$-gons, the tetrahedron, and the octahedron. It is not explicitly asked for, but it is easy to verify that all of these are indeed completely symmetric. Remark. On the IMO, a simpler version of this problem was adopted, adding the condition that $S$ belongs to a plane and thus eliminating the need for the second case altogether.


1. $\mathbf{C 1}$ (HUN) ${ }^{\mathrm{IMO}}$ A magician has one hundred cards numbered 1 to 100. He puts them into three boxes, a red one, a white one, and a blue one, so that each box contains at least one card. A member of the audience draws two cards from two different boxes and announces the sum of numbers on those cards. Given this information, the magician locates the box from which no card has been drawn. How many ways are there to put the cards in the three boxes so that the trick works?

Solution: 1. In order for the trick to work, whenever $x+y=z+t$ and the cards $x, y$ are placed in different boxes, either $z, t$ are in these boxes as well or they are both in the remaining box. Case 1. The cards $i, i+1, i+2$ are in different boxes for some $i$. Since $i+(i+3)=(i+1)+(i+2)$, the cards $i$ and $i+3$ must be in the same box; moreover, $i-1$ must be in the same box as $i+2$, etc. Hence the cards $1,4,7, \ldots, 100$ are placed in one box, the cards $2,5, \ldots, 98$ are in the second, while $3,6, \ldots, 99$ are in the third box. The number of different arrangements of the cards is 6 in this case. Case 2. No three successive cards are all placed in different boxes. Suppose that 1 is in the blue box, and denote by $w$ and $r$ the smallest numbers on cards lying in the white and red boxes; assume w.l.o.g. that $w<r$. The card $w+1$ is obviously not red, from which it follows that $r>$ $w+1$. Now suppose that $r<100$. Since $w+r=(w-1)+(r+1), r+1$ must be in the blue box. But then $(r+1)+w=r+(w+1)$ implies that $w+1$ must be red, which is a contradiction. Hence the red box contains only the card 100 . Since $99+w=100+(w-1)$, we deduce that the card 99 is in the white box. Moreover, if any of the cards $k$, $2 \leq k \leq 99$, were in the blue box, then since $k+99=(k-1)+100$, the card $k-1$ should be in the red box, which is impossible. Hence the blue box contains only the card 1 , whereas the cards $2,3, \ldots, 99$ are all in the white box. In general, one box contains 1 , another box only 100 , while the remaining contains all the other cards. There are exactly 6 such arrangements, and the trick works in each of them. Therefore the answer is 12.


10. A4 (GBR) The function $F$ is defined on the set of nonnegative integers and takes nonnegative integer values satisfying the following conditions: For every $n \geq 0$, (i) $F(4 n)=F(2 n)+F(n)$; (ii) $F(4 n+2)=F(4 n)+1$; (iii) $F(2 n+1)=F(2 n)+1$.  Prove that for each positive integer $m$, the number of integers $n$ with $0 \leq n<2^{m}$ and $F(4 n)=F(3 n)$ is $F\left(2^{m+1}\right)$.

Solution: 10. Clearly $F(0)=0$ by (i). Moreover, it follows by induction from (i) that $F\left(2^{n}\right)=f_{n+1}$ where $f_{n}$ denotes the $n$th Fibonacci's number. In general, if $n=\epsilon_{k} 2^{k}+\epsilon_{k-1} 2^{k-1}+\cdots+\epsilon_{1} \cdot 2+\epsilon_{0}$ (where $\epsilon_{i} \in\{0,1\}$ ), it is straightforward to verify that  $$ F(n)=\epsilon_{k} f_{k+1}+\epsilon_{k-1} f_{k}+\cdots+\epsilon_{1} f_{2}+\epsilon_{0} f_{1} $$  We observe that if the binary representation of $n$ contains no two adjacent ones, then $F(3 n)=F(4 n)$. Indeed, if $n=\epsilon_{k_{r}} 2^{k_{r}}+\cdots+\epsilon_{k_{0}} 2^{k_{0}}$, where $k_{i+1}-k_{i} \geq 2$ for all $i$, then $3 n=\epsilon_{k_{r}}\left(2^{k_{r}+1}+2^{k_{r}}\right)+\cdots+\epsilon_{k_{0}}\left(2^{k_{0}+1}+2^{k_{0}}\right)$. According to this, in computing $F(3 n)$ each $f_{i+1}$ in (1) is replaced by $f_{i+1}+f_{i+2}=f_{i+3}$, leading to the value of $F(4 n)$. We shall prove the converse: $F(3 n) \leq F(4 n)$ holds for all $n \geq 0$, with equality if and only if the binary representation of $n$ contains no two adjacent ones. We prove by induction on $m \geq 1$ that this holds for all $n$ satisfying $0 \leq n<$ $2^{m}$. The verification for the early values of $m$ is direct. Assume it is true for a certain $m$ and let $2^{m} \leq n \leq 2^{n+1}$. If $n=2^{m}+p, 0 \leq p<2^{m}$, then (1) implies $F(4 n)=F\left(2^{m+2}+4 p\right)=f_{m+3}+F(4 p)$. Now we distinguish three cases: (i) If $3 p<2^{m}$, then the binary representation of $3 p$ does not carry into that of $3 \cdot 2^{m}$. Then it follows from (1) and the induction hypothesis that $F(3 n)=F\left(3 \cdot 2^{m}\right)+F(3 p)=f_{m+3}+F(3 p) \leq f_{m+3}+F(4 p)=F(4 n)$. Equality holds if and only if $F(3 p)=F(4 p)$, i.e. $p$ has no two adjacent binary ones. (ii) If $2^{m} \leq 3 p<2^{m+1}$, then the binary representation of $3 p$ carries 1 into that of $3 \cdot 2^{m}$. Thus $F(3 n)=f_{m+3}+\left(F(3 p)-f_{m+1}\right)=f_{m+2}+F(3 p)<$ $f_{m+3}+F(4 p)=F(4 n)$. (iii) If $2^{m+1} \leq p<3 \cdot 2^{m}$, then the binary representation of $3 p$ caries 10 into that of $3 \cdot 2^{m}$, which implies  $$ F(3 n)=f_{m+3}+f_{m+1}+\left(F(3 p)-f_{m+2}\right)=2 f_{m+1}+F(3 p)<F(4 n) . $$  It remains to compute the number of integers in $\left[0,2^{m}\right)$ with no two adjacent binary 1's. Denote their number by $u_{m}$. Among them there are $u_{m-1}$ less than $2^{m-1}$ and $u_{m-2}$ in the segment $\left[2^{m-1}, 2^{m}\right)$. Hence $u_{m}=u_{m-1}+u_{m-2}$ for $m \geq 3$. Since $u_{1}=2=f_{3}, u_{2}=3=f_{4}$, we conclude that $u_{m}=f_{m+2}=F\left(2^{m+1}\right)$.


11. A5 (BLR) ${ }^{\mathrm{IMO} 3}$ Let $n \geq 2$ be a positive integer and $\lambda$ a positive real number. Initially there are $n$ fleas on a horizontal line, not all at the same point. We define a move of choosing two fleas at some points $A$ and $B$, with $A$ to the left of $B$, and letting the flea from $A$ jump over the flea from $B$ to the point $C$ such that $B C / A B=\lambda$. Determine all values of $\lambda$ such that for any point $M$ on the line and for any initial position of the $n$ fleas, there exists a sequence of moves that will take them all to the position right of $M$.

Solution: 11. We claim that for $\lambda \geq \frac{1}{n-1}$ we can take all fleas as far to the right as we want. In every turn we choose the leftmost flea and let it jump over the rightmost one. Let $d$ and $\delta$ denote the maximal and the minimal distances between two fleas at some moment. Clearly, $d \geq(n-1) \delta$. After the leftmost flea jumps over the rightmost one, the minimal distance does not decrease, because $\lambda d \geq \delta$. However, the position of the leftmost flea moved to the right by at least $\delta$, and consequently we can move the fleas arbitrarily far to the right after a finite number of moves. Suppose now that $\lambda<\frac{1}{n-1}$. Under this assumption we shall prove that there is a number $M$ that cannot be reached by any flea. Let us assign to each flea the coordinate on the real axis in which it is settled. Denote by $s_{k}$ the sum of all the numbers in the $k$ th step, and by $w_{k}$ the coordinate of the rightmost flea. Clearly, $s_{k} \leq n w_{k}$. We claim that the sequence $w_{k}$ is bounded. In the $(k+1)$ th move let a flea $A$ jump over $B$, landing at $C$, and let $a, b, c$ be their respective coordinates. We have $s_{k+1}-s_{k}=c-a$. Then by the given rule, $\lambda(b-a)=c-b=s_{k+1}-s_{k}+a-b$, which implies $s_{k+1}-s_{k}=$ $(1+\lambda)(b-a)=\frac{1+\lambda}{\lambda}(c-b)$. Hence $s_{k+1}-s_{k} \geq \frac{1+\lambda}{\lambda}\left(w_{k+1}-w_{k}\right)$. Summing up these inequalities for $k=0, \ldots, n-1$ yields $s_{n}-s_{0} \geq \frac{1+\lambda}{\lambda}\left(w_{n}-w_{0}\right)$. Now using $s_{n} \leq n w_{n}$ we conclude that  $$ \left(\frac{1+\lambda}{\lambda}-n\right) w_{n} \leq \frac{1+\lambda}{\lambda} w_{0}-s_{0} . $$  Since $\frac{1+\lambda}{\lambda}-n>0$, this proves the result.


12. A6 (IRE) A nonempty set $A$ of real numbers is called a $B_{3}$-set if the conditions $a_{1}, a_{2}, a_{3}, a_{4}, a_{5}, a_{6} \in A$ and $a_{1}+a_{2}+a_{3}=a_{4}+a_{5}+a_{6}$ imply that the sequences $\left(a_{1}, a_{2}, a_{3}\right)$ and $\left(a_{4}, a_{5}, a_{6}\right)$ are identical up to a permutation. Let $A=\left\{a_{0}=0<a_{1}<a_{2}<\cdots\right\}, B=\left\{b_{0}=0<b_{1}<b_{2}<\cdots\right\}$ be infinite sequences of real numbers with $D(A)=D(B)$, where, for a set $X$ of real numbers, $D(X)$ denotes the difference set $\{|x-y| \mid x, y \in X\}$. Prove that if $A$ is a $B_{3}$-set, then $A=B$.

Solution: 12. Since $D(A)=D(B)$, we can define $f(i)>g(i) \geq 0$ that satisfy $b_{i}-b_{i-1}=$ $a_{f(i)}-a_{g(i)}$ for all $i$. The number $b_{i+1}-b_{i-1} \in D(B)=D(A)$ can be written in the form $a_{u}-a_{v}, u>v \geq 0$. Then $b_{i+1}-b_{i-1}=b_{i+1}-b_{i}+b_{i}-b_{i-1}$ implies $a_{f(i+1)}+a_{f(i)}+a_{v}=a_{g(i+1)}+a_{g(i)}+a_{u}$, so the $B_{3}$ property of $A$ implies that $(f(i+1), f(i), v)$ and $(g(i+1), g(i), u)$ coincide up to a permutation. It follows that either $f(i+1)=g(i)$ or $f(i)=g(i+1)$. Hence if we define $R=\left\{i \in \mathbb{N}_{0} \mid f(i+1)=g(i)\right\}$ and $S=\left\{i \in \mathbb{N}_{0} \mid f(i)=g(i+1)\right\}$ it holds that $R \cup S=\mathbb{N}_{0}$. Lemma. If $i \in R$, then also $i+1 \in R$. Proof. Suppose to the contrary that $i \in R$ and $i+1 \in S$, i.e., $g(i)=$ $f(i+1)=g(i+2)$. There are integers $x$ and $y$ such that $b_{i+2}-b_{i-1}=$ $a_{x}-a_{y}$. Then $a_{x}-a_{y}=a_{f(i+2)}-a_{g(i+2)}+a_{f(i+1)}-a_{g(i+1)}+a_{f(i)}-$ $a_{g(i)}=a_{f(i+2)}+a_{f(i)}-a_{g(i+1)}-a_{g(i)}$, so by the $B_{3}$ property $(x, g(i+$ $1), g(i))$ and $(y, f(i+2), f(i))$ coincide up to a permutation. But this is impossible, since $f(i+2), f(i)>g(i+2)=g(i)=f(i+1)>g(i+1)$. This proves the lemma. Therefore if $i \in R \neq \emptyset$, then it follows that every $j>i$ belongs to $R$. Consequently $g(i)=f(i+1)>g(i+1)=f(i+2)>g(i+2)=f(i+3)>$ $\cdots$ is an infinite decreasing sequence of nonnegative integers, which is impossible. Hence $S=\mathbb{N}_{0}$, i.e.,  $$ b_{i+1}-b_{i}=a_{f(i+1)}-a_{f(i)} \quad \text { for all } i \in \mathbb{N}_{0} $$  Thus $f(0)=g(1)<f(1)<f(2)<\cdots$, implying $f(i) \geq i$. On the other hand, for any $i$ there exist $j, k$ such that $a_{f(i)}-a_{i}=b_{j}-b_{k}=a_{f(j)}-a_{f(k)}$, so by the $B_{3}$ property $i \in\{f(i), f(k)\}$ is a value of $f$. Hence we must have $f(i)=i$ for all $i$, which finally gives $A=B$.