Solution: Denote by $\omega$ and $O$ the circumcircle of the triangle $A B C$ and its center, respectively. From the condition $\angle P B A=\angle B C A$ we know that $B P$ is tangent to $\omega$.  Let $E$ be the second point of intersection of $\omega$ and $B D$. Due to the isosceles triangle $B D P$, the tangent of $\omega$ at $E$ is parallel to $D P$ and consequently it intersects $B P$ at some point $L$. Of course, $P D \| L E$. Let $M$ be the midpoint of $B E$, and let $H$ be the midpoint of $B R$. Notice that $\angle A E B=\angle A C B=\angle A B Q=\angle A B E$, so $A$ lies on the perpendicular bisector of $B E$; thus the points $L, A, M$, and $O$ are collinear. Let $\omega_{1}$ be the circle with diameter $B O$. Let $Q^{\prime}=H O \cap B E$; since $H O$ is the perpendicular bisector of $B R$, the statement of the problem is equivalent to $Q^{\prime}=Q$.  Consider the following sequence of projections (see Fig. 3).  1. Project the line $B E$ to the line $L B$ through the center $A$. (This maps $Q$ to $P$.) 2. Project the line $L B$ to $B E$ in parallel direction with $L E$. $(P \mapsto D$.) 3. Project the line $B E$ to the circle $\omega$ through its point $A .(D \mapsto R$.) 4. Scale $\omega$ by the ratio $\frac{1}{2}$ from the point $B$ to the circle $\omega_{1} .(R \mapsto H$. 5. Project $\omega_{1}$ to the line $B E$ through its point $O$. $\left(H \mapsto Q^{\prime}\right.$.)  We prove that the composition of these transforms, which maps the line $B E$ to itself, is the identity. To achieve this, it suffices to show three fixed points. An obvious fixed point is $B$ which is fixed by all the transformations above. Another fixed point is $M$, its path being $M \mapsto L \mapsto$ $E \mapsto E \mapsto M \mapsto M$.  ![](https://cdn.mathpix.com/cropped/2024_04_17_e0914cb4f8055c731538g-45.jpg?height=800&width=786&top_left_y=218&top_left_x=279)  Figure 3  ![](https://cdn.mathpix.com/cropped/2024_04_17_e0914cb4f8055c731538g-45.jpg?height=786&width=759&top_left_y=233&top_left_x=1125)  Figure 4  In order to show a third fixed point, draw a line parallel with $L E$ through $A$; let that line intersect $B E, L B$ and $\omega$ at $X, Y$ and $Z \neq A$, respectively (see Fig. 4). We show that $X$ is a fixed point. The images of $X$ at the first three transformations are $X \mapsto Y \mapsto X \mapsto Z$. From $\angle X B Z=\angle E A Z=\angle A E L=\angle L B A=\angle B Z X$ we can see that the triangle $X B Z$ is isosceles. Let $U$ be the midpoint of $B Z$; then the last two transformations do $Z \mapsto U \mapsto X$, and the point $X$ is fixed.  Comment. Verifying that the point $E$ is fixed seems more natural at first, but it appears to be less straightforward. Here we outline a possible proof.  Let the images of $E$ at the first three transforms above be $F, G$ and $I$. After comparing the angles depicted in Fig. 5 (noticing that the quadrilateral $A F B G$ is cyclic) we can observe that the tangent $L E$ of $\omega$ is parallel to $B I$. Then, similarly to the above reasons, the point $E$ is also fixed.  ![](https://cdn.mathpix.com/cropped/2024_04_17_e0914cb4f8055c731538g-45.jpg?height=789&width=751&top_left_y=1687&top_left_x=687)  Figure 5


Let $A B C D E F$ be a convex hexagon with $A B=D E, B C=E F, C D=F A$, and $\angle A-\angle D=\angle C-\angle F=\angle E-\angle B$. Prove that the diagonals $A D, B E$, and $C F$ are concurrent.  (Ukraine)

Solution: Let $x=A B=D E, y=C D=F A, z=E F=B C$. Consider the points $P, Q$, and $R$ such that the quadrilaterals $C D E P, E F A Q$, and $A B C R$ are parallelograms. We compute  $$ \begin{aligned} \angle P E Q & =\angle F E Q+\angle D E P-\angle E=\left(180^{\circ}-\angle F\right)+\left(180^{\circ}-\angle D\right)-\angle E \\ & =360^{\circ}-\angle D-\angle E-\angle F=\frac{1}{2}(\angle A+\angle B+\angle C-\angle D-\angle E-\angle F)=\theta / 2 \end{aligned} $$  Similarly, $\angle Q A R=\angle R C P=\theta / 2$.  ![](https://cdn.mathpix.com/cropped/2024_04_17_e0914cb4f8055c731538g-46.jpg?height=491&width=827&top_left_y=947&top_left_x=649)  If $\theta=0$, since $\triangle R C P$ is isosceles, $R=P$. Therefore $A B\|R C=P C\| E D$, so $A B D E$ is a parallelogram. Similarly, $B C E F$ and $C D F A$ are parallelograms. It follows that $A D, B E$ and $C F$ meet at their common midpoint.  Now assume $\theta>0$. Since $\triangle P E Q, \triangle Q A R$, and $\triangle R C P$ are isosceles and have the same angle at the apex, we have $\triangle P E Q \sim \triangle Q A R \sim \triangle R C P$ with ratios of similarity $y: z: x$. Thus  $\triangle P Q R$ is similar to the triangle with sidelengths $y, z$, and $x$.  Next, notice that  $$ \frac{R Q}{Q P}=\frac{z}{y}=\frac{R A}{A F} $$  and, using directed angles between rays,  $$ \begin{aligned} \not(R Q, Q P) & =\Varangle(R Q, Q E)+\Varangle(Q E, Q P) \\ & =\Varangle(R Q, Q E)+\Varangle(R A, R Q)=\Varangle(R A, Q E)=\Varangle(R A, A F) . \end{aligned} $$  Thus $\triangle P Q R \sim \triangle F A R$. Since $F A=y$ and $A R=z$, (1) then implies that $F R=x$. Similarly $F P=x$. Therefore $C R F P$ is a rhombus.  We conclude that $C F$ is the perpendicular bisector of $P R$. Similarly, $B E$ is the perpendicular bisector of $P Q$ and $A D$ is the perpendicular bisector of $Q R$. It follows that $A D, B E$, and $C F$ are concurrent at the circumcenter of $P Q R$.


Solution: Let $X=C D \cap E F, Y=E F \cap A B, Z=A B \cap C D, X^{\prime}=F A \cap B C, Y^{\prime}=$ $B C \cap D E$, and $Z^{\prime}=D E \cap F A$. From $\angle A+\angle B+\angle C=360^{\circ}+\theta / 2$ we get $\angle A+\angle B>180^{\circ}$ and $\angle B+\angle C>180^{\circ}$, so $Z$ and $X^{\prime}$ are respectively on the opposite sides of $B C$ and $A B$ from the hexagon. Similar conclusions hold for $X, Y, Y^{\prime}$, and $Z^{\prime}$. Then  $$ \angle Y Z X=\angle B+\angle C-180^{\circ}=\angle E+\angle F-180^{\circ}=\angle Y^{\prime} Z^{\prime} X^{\prime}, $$  and similarly $\angle Z X Y=\angle Z^{\prime} X^{\prime} Y^{\prime}$ and $\angle X Y Z=\angle X^{\prime} Y^{\prime} Z^{\prime}$, so $\triangle X Y Z \sim \triangle X^{\prime} Y^{\prime} Z^{\prime}$. Thus there is a rotation $R$ which sends $\triangle X Y Z$ to a triangle with sides parallel to $\triangle X^{\prime} Y^{\prime} Z^{\prime}$. Since $A B=D E$ we have $R(\overrightarrow{A B})=\overrightarrow{D E}$. Similarly, $R(\overrightarrow{C D})=\overrightarrow{F A}$ and $R(\overrightarrow{E F})=\overrightarrow{B C}$. Therefore  $$ \overrightarrow{0}=\overrightarrow{A B}+\overrightarrow{B C}+\overrightarrow{C D}+\overrightarrow{D E}+\overrightarrow{E F}+\overrightarrow{F A}=(\overrightarrow{A B}+\overrightarrow{C D}+\overrightarrow{E F})+R(\overrightarrow{A B}+\overrightarrow{C D}+\overrightarrow{E F}) $$  If $R$ is a rotation by $180^{\circ}$, then any two opposite sides of our hexagon are equal and parallel, so the three diagonals meet at their common midpoint. Otherwise, we must have  $$ \overrightarrow{A B}+\overrightarrow{C D}+\overrightarrow{E F}=\overrightarrow{0} $$  or else we would have two vectors with different directions whose sum is $\overrightarrow{0}$.  ![](https://cdn.mathpix.com/cropped/2024_04_17_e0914cb4f8055c731538g-47.jpg?height=689&width=1333&top_left_y=1057&top_left_x=388)  This allows us to consider a triangle $L M N$ with $\overrightarrow{L M}=\overrightarrow{E F}, \overrightarrow{M N}=\overrightarrow{A B}$, and $\overrightarrow{N L}=\overrightarrow{C D}$. Let $O$ be the circumcenter of $\triangle L M N$ and consider the points $O_{1}, O_{2}, O_{3}$ such that $\triangle A O_{1} B, \triangle C O_{2} D$, and $\triangle E O_{3} F$ are translations of $\triangle M O N, \triangle N O L$, and $\triangle L O M$, respectively. Since $F O_{3}$ and $A O_{1}$ are translations of $M O$, quadrilateral $A F O_{3} O_{1}$ is a parallelogram and $O_{3} O_{1}=F A=C D=N L$. Similarly, $O_{1} O_{2}=L M$ and $O_{2} O_{3}=M N$. Therefore $\triangle O_{1} O_{2} O_{3} \cong \triangle L M N$. Moreover, by means of the rotation $R$ one may check that these triangles have the same orientation.  Let $T$ be the circumcenter of $\triangle O_{1} O_{2} O_{3}$. We claim that $A D, B E$, and $C F$ meet at $T$. Let us show that $C, T$, and $F$ are collinear. Notice that $C O_{2}=O_{2} T=T O_{3}=O_{3} F$ since they are all equal to the circumradius of $\triangle L M N$. Therefore $\triangle T O_{3} F$ and $\triangle C O_{2} T$ are isosceles. Using directed angles between rays again, we get  $$ \Varangle\left(T F, T O_{3}\right)=\Varangle\left(F O_{3}, F T\right) \quad \text { and } \quad \Varangle\left(T O_{2}, T C\right)=\Varangle\left(C T, C O_{2}\right) \text {. } $$  Also, $T$ and $O$ are the circumcenters of the congruent triangles $\triangle O_{1} O_{2} O_{3}$ and $\triangle L M N$ so we have $\Varangle\left(T O_{3}, T O_{2}\right)=\Varangle(O N, O M)$. Since $C_{2}$ and $F O_{3}$ are translations of $N O$ and $M O$ respectively, this implies  $$ \Varangle\left(T O_{3}, T O_{2}\right)=\Varangle\left(C O_{2}, F O_{3}\right) . $$  Adding the three equations in (2) and (3) gives  $$ \Varangle(T F, T C)=\Varangle(C T, F T)=-\not(T F, T C) $$  which implies that $T$ is on $C F$. Analogous arguments show that it is on $A D$ and $B E$ also. The desired result follows.


Solution: Place the hexagon on the complex plane, with $A$ at the origin and vertices labelled clockwise. Now $A, B, C, D, E, F$ represent the corresponding complex numbers. Also consider the complex numbers $a, b, c, a^{\prime}, b^{\prime}, c^{\prime}$ given by $B-A=a, D-C=b, F-E=c, E-D=a^{\prime}$, $A-F=b^{\prime}$, and $C-B=c^{\prime}$. Let $k=|a| /|b|$. From $a / b^{\prime}=-k e^{i \angle A}$ and $a^{\prime} / b=-k e^{i \angle D}$ we get that $\left(a^{\prime} / a\right)\left(b^{\prime} / b\right)=e^{-i \theta}$ and similarly $\left(b^{\prime} / b\right)\left(c^{\prime} / c\right)=e^{-i \theta}$ and $\left(c^{\prime} / c\right)\left(a^{\prime} / a\right)=e^{-i \theta}$. It follows that $a^{\prime}=a r$, $b^{\prime}=b r$, and $c^{\prime}=c r$ for a complex number $r$ with $|r|=1$, as shown below.  ![](https://cdn.mathpix.com/cropped/2024_04_17_e0914cb4f8055c731538g-48.jpg?height=512&width=1052&top_left_y=823&top_left_x=534)  We have  $$ 0=a+c r+b+a r+c+b r=(a+b+c)(1+r) . $$  If $r=-1$, then the hexagon is centrally symmetric and its diagonals intersect at its center of symmetry. Otherwise  $$ a+b+c=0 \text {. } $$  Therefore  $$ A=0, \quad B=a, \quad C=a+c r, \quad D=c(r-1), \quad E=-b r-c, \quad F=-b r . $$  Now consider a point $W$ on $A D$ given by the complex number $c(r-1) \lambda$, where $\lambda$ is a real number with $0<\lambda<1$. Since $D \neq A$, we have $r \neq 1$, so we can define $s=1 /(r-1)$. From $r \bar{r}=|r|^{2}=1$ we get  $$ 1+s=\frac{r}{r-1}=\frac{r}{r-r \bar{r}}=\frac{1}{1-\bar{r}}=-\bar{s} . $$  Now,  $$ \begin{aligned} W \text { is on } B E & \Longleftrightarrow c(r-1) \lambda-a\|a-(-b r-c)=b(r-1) \Longleftrightarrow c \lambda-a s\| b \\ & \Longleftrightarrow-a \lambda-b \lambda-a s\|b \Longleftrightarrow a(\lambda+s)\| b . \end{aligned} $$  One easily checks that $r \neq \pm 1$ implies that $\lambda+s \neq 0$ since $s$ is not real. On the other hand,  $$ \begin{aligned} W \text { on } C F & \Longleftrightarrow c(r-1) \lambda+b r\|-b r-(a+c r)=a(r-1) \Longleftrightarrow c \lambda+b(1+s)\| a \\ & \Longleftrightarrow-a \lambda-b \lambda-b \bar{s}\|a \Longleftrightarrow b(\lambda+\bar{s})\| a \Longleftrightarrow b \| a(\lambda+s), \end{aligned} $$  where in the last step we use that $(\lambda+s)(\lambda+\bar{s})=|\lambda+s|^{2} \in \mathbb{R}_{>0}$. We conclude that $A D \cap B E=$ $C F \cap B E$, and the desired result follows.


Let the excircle of the triangle $A B C$ lying opposite to $A$ touch its side $B C$ at the point $A_{1}$. Define the points $B_{1}$ and $C_{1}$ analogously. Suppose that the circumcentre of the triangle $A_{1} B_{1} C_{1}$ lies on the circumcircle of the triangle $A B C$. Prove that the triangle $A B C$ is right-angled.  (Russia)

Solution: Denote the circumcircles of the triangles $A B C$ and $A_{1} B_{1} C_{1}$ by $\Omega$ and $\Gamma$, respectively. Denote the midpoint of the arc $C B$ of $\Omega$ containing $A$ by $A_{0}$, and define $B_{0}$ as well as $C_{0}$ analogously. By our hypothesis the centre $Q$ of $\Gamma$ lies on $\Omega$.  Lemma. One has $A_{0} B_{1}=A_{0} C_{1}$. Moreover, the points $A, A_{0}, B_{1}$, and $C_{1}$ are concyclic. Finally, the points $A$ and $A_{0}$ lie on the same side of $B_{1} C_{1}$. Similar statements hold for $B$ and $C$.  Proof. Let us consider the case $A=A_{0}$ first. Then the triangle $A B C$ is isosceles at $A$, which implies $A B_{1}=A C_{1}$ while the remaining assertions of the Lemma are obvious. So let us suppose $A \neq A_{0}$ from now on.  By the definition of $A_{0}$, we have $A_{0} B=A_{0} C$. It is also well known and easy to show that $B C_{1}=$ $C B_{1}$. Next, we have $\angle C_{1} B A_{0}=\angle A B A_{0}=\angle A C A_{0}=\angle B_{1} C A_{0}$. Hence the triangles $A_{0} B C_{1}$ and $A_{0} C B_{1}$ are congruent. This implies $A_{0} C_{1}=A_{0} B_{1}$, establishing the first part of the Lemma. It also follows that $\angle A_{0} C_{1} A=\angle A_{0} B_{1} A$, as these are exterior angles at the corresponding vertices $C_{1}$ and $B_{1}$ of the congruent triangles $A_{0} B C_{1}$ and $A_{0} C B_{1}$. For that reason the points $A, A_{0}, B_{1}$, and $C_{1}$ are indeed the vertices of some cyclic quadrilateral two opposite sides of which are $A A_{0}$ and $B_{1} C_{1}$.  Now we turn to the solution. Evidently the points $A_{1}, B_{1}$, and $C_{1}$ lie interior to some semicircle arc of $\Gamma$, so the triangle $A_{1} B_{1} C_{1}$ is obtuse-angled. Without loss of generality, we will assume that its angle at $B_{1}$ is obtuse. Thus $Q$ and $B_{1}$ lie on different sides of $A_{1} C_{1}$; obviously, the same holds for the points $B$ and $B_{1}$. So, the points $Q$ and $B$ are on the same side of $A_{1} C_{1}$.  Notice that the perpendicular bisector of $A_{1} C_{1}$ intersects $\Omega$ at two points lying on different sides of $A_{1} C_{1}$. By the first statement from the Lemma, both points $B_{0}$ and $Q$ are among these points of intersection; since they share the same side of $A_{1} C_{1}$, they coincide (see Figure 1).  ![](https://cdn.mathpix.com/cropped/2024_04_17_e0914cb4f8055c731538g-49.jpg?height=781&width=827&top_left_y=1667&top_left_x=649)  Figure 1  Now, by the first part of the Lemma again, the lines $Q A_{0}$ and $Q C_{0}$ are the perpendicular bisectors of $B_{1} C_{1}$ and $A_{1} B_{1}$, respectively. Thus  $$ \angle C_{1} B_{0} A_{1}=\angle C_{1} B_{0} B_{1}+\angle B_{1} B_{0} A_{1}=2 \angle A_{0} B_{0} B_{1}+2 \angle B_{1} B_{0} C_{0}=2 \angle A_{0} B_{0} C_{0}=180^{\circ}-\angle A B C $$  recalling that $A_{0}$ and $C_{0}$ are the midpoints of the arcs $C B$ and $B A$, respectively.  On the other hand, by the second part of the Lemma we have  $$ \angle C_{1} B_{0} A_{1}=\angle C_{1} B A_{1}=\angle A B C . $$  From the last two equalities, we get $\angle A B C=90^{\circ}$, whereby the problem is solved.


Solution: Let $Q$ again denote the centre of the circumcircle of the triangle $A_{1} B_{1} C_{1}$, that lies on the circumcircle $\Omega$ of the triangle $A B C$. We first consider the case where $Q$ coincides with one of the vertices of $A B C$, say $Q=B$. Then $B C_{1}=B A_{1}$ and consequently the triangle $A B C$ is isosceles at $B$. Moreover we have $B C_{1}=B_{1} C$ in any triangle, and hence $B B_{1}=B C_{1}=B_{1} C$; similarly, $B B_{1}=B_{1} A$. It follows that $B_{1}$ is the centre of $\Omega$ and that the triangle $A B C$ has a right angle at $B$.  So from now on we may suppose $Q \notin\{A, B, C\}$. We start with the following well known fact. Lemma. Let $X Y Z$ and $X^{\prime} Y^{\prime} Z^{\prime}$ be two triangles with $X Y=X^{\prime} Y^{\prime}$ and $Y Z=Y^{\prime} Z^{\prime}$.  (i) If $X Z \neq X^{\prime} Z^{\prime}$ and $\angle Y Z X=\angle Y^{\prime} Z^{\prime} X^{\prime}$, then $\angle Z X Y+\angle Z^{\prime} X^{\prime} Y^{\prime}=180^{\circ}$.  (ii) If $\angle Y Z X+\angle X^{\prime} Z^{\prime} Y^{\prime}=180^{\circ}$, then $\angle Z X Y=\angle Y^{\prime} X^{\prime} Z^{\prime}$.  Proof. For both parts, we may move the triangle $X Y Z$ through the plane until $Y=Y^{\prime}$ and $Z=Z^{\prime}$. Possibly after reflecting one of the two triangles about $Y Z$, we may also suppose that $X$ and $X^{\prime}$ lie on the same side of $Y Z$ if we are in case (i) and on different sides if we are in case (ii). In both cases, the points $X, Z$, and $X^{\prime}$ are collinear due to the angle condition (see Fig. 2). Moreover we have $X \neq X^{\prime}$, because in case (i) we assumed $X Z \neq X^{\prime} Z^{\prime}$ and in case (ii) these points even lie on different sides of $Y Z$. Thus the triangle $X X^{\prime} Y$ is isosceles at $Y$. The claim now follows by considering the equal angles at its base.  ![](https://cdn.mathpix.com/cropped/2024_04_17_e0914cb4f8055c731538g-50.jpg?height=304&width=460&top_left_y=1732&top_left_x=518)  Figure 2(i)  ![](https://cdn.mathpix.com/cropped/2024_04_17_e0914cb4f8055c731538g-50.jpg?height=304&width=464&top_left_y=1732&top_left_x=1123)  Figure 2(ii)  Relabeling the vertices of the triangle $A B C$ if necessary we may suppose that $Q$ lies in the interior of the arc $A B$ of $\Omega$ not containing $C$. We will sometimes use tacitly that the six triangles $Q B A_{1}, Q A_{1} C, Q C B_{1}, Q B_{1} A, Q C_{1} A$, and $Q B C_{1}$ have the same orientation.  As $Q$ cannot be the circumcentre of the triangle $A B C$, it is impossible that $Q A=Q B=Q C$ and thus we may also suppose that $Q C \neq Q B$. Now the above Lemma $(i)$ is applicable to the triangles $Q B_{1} C$ and $Q C_{1} B$, since $Q B_{1}=Q C_{1}$ and $B_{1} C=C_{1} B$, while $\angle B_{1} C Q=\angle C_{1} B Q$ holds as both angles appear over the same side of the chord $Q A$ in $\Omega$ (see Fig. 3). So we get  $$ \angle C Q B_{1}+\angle B Q C_{1}=180^{\circ} . $$  We claim that $Q C=Q A$. To see this, let us assume for the sake of a contradiction that $Q C \neq Q A$. Then arguing similarly as before but now with the triangles $Q A_{1} C$ and $Q C_{1} A$ we get  $$ \angle A_{1} Q C+\angle C_{1} Q A=180^{\circ} \text {. } $$  Adding this equation to (1), we get $\angle A_{1} Q B_{1}+\angle B Q A=360^{\circ}$, which is absurd as both summands lie in the interval $\left(0^{\circ}, 180^{\circ}\right)$.  This proves $Q C=Q A$; so the triangles $Q A_{1} C$ and $Q C_{1} A$ are congruent their sides being equal, which in turn yields  $$ \angle A_{1} Q C=\angle C_{1} Q A \text {. } $$  Finally our Lemma (ii) is applicable to the triangles $Q A_{1} B$ and $Q B_{1} A$. Indeed we have $Q A_{1}=Q B_{1}$ and $A_{1} B=B_{1} A$ as usual, and the angle condition $\angle A_{1} B Q+\angle Q A B_{1}=180^{\circ}$ holds as $A$ and $B$ lie on different sides of the chord $Q C$ in $\Omega$. Consequently we have  $$ \angle B Q A_{1}=\angle B_{1} Q A \text {. } $$  From (1) and (3) we get  $$ \left(\angle B_{1} Q C+\angle B_{1} Q A\right)+\left(\angle C_{1} Q B-\angle B Q A_{1}\right)=180^{\circ} \text {, } $$  i.e. $\angle C Q A+\angle A_{1} Q C_{1}=180^{\circ}$. In light of (2) this may be rewritten as $2 \angle C Q A=180^{\circ}$ and as $Q$ lies on $\Omega$ this implies that the triangle $A B C$ has a right angle at $B$.  ![](https://cdn.mathpix.com/cropped/2024_04_17_e0914cb4f8055c731538g-51.jpg?height=569&width=908&top_left_y=1404&top_left_x=606)  Figure 3  Comment 1. One may also check that $Q$ is in the interior of $\Omega$ if and only if the triangle $A B C$ is acute-angled.  Comment 2. The original proposal asked to prove the converse statement as well: if the triangle $A B C$ is right-angled, then the point $Q$ lies on its circumcircle. The Problem Selection Committee thinks that the above simplified version is more suitable for the competition.


Let $\mathbb{Z}_{>0}$ be the set of positive integers. Find all functions $f: \mathbb{Z}_{>0} \rightarrow \mathbb{Z}_{>0}$ such that  $$ m^{2}+f(n) \mid m f(m)+n $$  for all positive integers $m$ and $n$.  (Malaysia)

Solution: Setting $m=n=2$ tells us that $4+f(2) \mid 2 f(2)+2$. Since $2 f(2)+2<2(4+f(2))$, we must have $2 f(2)+2=4+f(2)$, so $f(2)=2$. Plugging in $m=2$ then tells us that $4+f(n) \mid 4+n$, which implies that $f(n) \leqslant n$ for all $n$.  Setting $m=n$ gives $n^{2}+f(n) \mid n f(n)+n$, so $n f(n)+n \geqslant n^{2}+f(n)$ which we rewrite as $(n-1)(f(n)-n) \geqslant 0$. Therefore $f(n) \geqslant n$ for all $n \geqslant 2$. This is trivially true for $n=1$ also.  It follows that $f(n)=n$ for all $n$. This function obviously satisfies the desired property.


Solution: Setting $m=f(n)$ we get $f(n)(f(n)+1) \mid f(n) f(f(n))+n$. This implies that $f(n) \mid n$ for all $n$.  Now let $m$ be any positive integer, and let $p>2 m^{2}$ be a prime number. Note that $p>m f(m)$ also. Plugging in $n=p-m f(m)$ we learn that $m^{2}+f(n)$ divides $p$. Since $m^{2}+f(n)$ cannot equal 1, it must equal $p$. Therefore $p-m^{2}=f(n) \mid n=p-m f(m)$. But $p-m f(m)<p<2\left(p-m^{2}\right)$, so we must have $p-m f(m)=p-m^{2}$, i.e., $f(m)=m$.


Solution: Plugging $m=1$ we obtain $1+f(n) \leqslant f(1)+n$, so $f(n) \leqslant n+c$ for the constant $c=$ $f(1)-1$. Assume that $f(n) \neq n$ for some fixed $n$. When $m$ is large enough (e.g. $m \geqslant \max (n, c+1)$ ) we have  $$ m f(m)+n \leqslant m(m+c)+n \leqslant 2 m^{2}<2\left(m^{2}+f(n)\right), $$  so we must have $m f(m)+n=m^{2}+f(n)$. This implies that  $$ 0 \neq f(n)-n=m(f(m)-m) $$  which is impossible for $m>|f(n)-n|$. It follows that $f$ is the identity function.


Prove that for any pair of positive integers $k$ and $n$ there exist $k$ positive integers $m_{1}, m_{2}, \ldots, m_{k}$ such that  $$ 1+\frac{2^{k}-1}{n}=\left(1+\frac{1}{m_{1}}\right)\left(1+\frac{1}{m_{2}}\right) \cdots\left(1+\frac{1}{m_{k}}\right) . $$  (Japan)

Solution: We proceed by induction on $k$. For $k=1$ the statement is trivial. Assuming we have proved it for $k=j-1$, we now prove it for $k=j$.  Case 1. $n=2 t-1$ for some positive integer $t$.  Observe that  $$ 1+\frac{2^{j}-1}{2 t-1}=\frac{2\left(t+2^{j-1}-1\right)}{2 t} \cdot \frac{2 t}{2 t-1}=\left(1+\frac{2^{j-1}-1}{t}\right)\left(1+\frac{1}{2 t-1}\right) . $$  By the induction hypothesis we can find $m_{1}, \ldots, m_{j-1}$ such that  $$ 1+\frac{2^{j-1}-1}{t}=\left(1+\frac{1}{m_{1}}\right)\left(1+\frac{1}{m_{2}}\right) \cdots\left(1+\frac{1}{m_{j-1}}\right) $$  so setting $m_{j}=2 t-1$ gives the desired expression.  Case 2. $n=2 t$ for some positive integer $t$.  Now we have  $$ 1+\frac{2^{j}-1}{2 t}=\frac{2 t+2^{j}-1}{2 t+2^{j}-2} \cdot \frac{2 t+2^{j}-2}{2 t}=\left(1+\frac{1}{2 t+2^{j}-2}\right)\left(1+\frac{2^{j-1}-1}{t}\right) $$  noting that $2 t+2^{j}-2>0$. Again, we use that  $$ 1+\frac{2^{j-1}-1}{t}=\left(1+\frac{1}{m_{1}}\right)\left(1+\frac{1}{m_{2}}\right) \cdots\left(1+\frac{1}{m_{j-1}}\right) . $$  Setting $m_{j}=2 t+2^{j}-2$ then gives the desired expression.


Solution: Consider the base 2 expansions of the residues of $n-1$ and $-n$ modulo $2^{k}$ :  $$ \begin{aligned} n-1 & \equiv 2^{a_{1}}+2^{a_{2}}+\cdots+2^{a_{r}}\left(\bmod 2^{k}\right) & & \text { where } 0 \leqslant a_{1}<a_{2}<\ldots<a_{r} \leqslant k-1 \\ -n & \equiv 2^{b_{1}}+2^{b_{2}}+\cdots+2^{b_{s}}\left(\bmod 2^{k}\right) & & \text { where } 0 \leqslant b_{1}<b_{2}<\ldots<b_{s} \leqslant k-1 . \end{aligned} $$  Since $-1 \equiv 2^{0}+2^{1}+\cdots+2^{k-1}\left(\bmod 2^{k}\right)$, we have $\left\{a_{1}, \ldots, a_{r}\right\} \cup\left\{b_{1} \ldots, b_{s}\right\}=\{0,1, \ldots, k-1\}$ and $r+s=k$. Write  $$ \begin{aligned} & S_{p}=2^{a_{p}}+2^{a_{p+1}}+\cdots+2^{a_{r}} \quad \text { for } 1 \leqslant p \leqslant r, \\ & T_{q}=2^{b_{1}}+2^{b_{2}}+\cdots+2^{b_{q}} \quad \text { for } 1 \leqslant q \leqslant s . \end{aligned} $$  Also set $S_{r+1}=T_{0}=0$. Notice that $S_{1}+T_{s}=2^{k}-1$ and $n+T_{s} \equiv 0\left(\bmod 2^{k}\right)$. We have  $$ \begin{aligned} 1+\frac{2^{k}-1}{n} & =\frac{n+S_{1}+T_{s}}{n}=\frac{n+S_{1}+T_{s}}{n+T_{s}} \cdot \frac{n+T_{s}}{n} \\ & =\prod_{p=1}^{r} \frac{n+S_{p}+T_{s}}{n+S_{p+1}+T_{s}} \cdot \prod_{q=1}^{s} \frac{n+T_{q}}{n+T_{q-1}} \\ & =\prod_{p=1}^{r}\left(1+\frac{2^{a_{p}}}{n+S_{p+1}+T_{s}}\right) \cdot \prod_{q=1}^{s}\left(1+\frac{2^{b_{q}}}{n+T_{q-1}}\right), \end{aligned} $$  so if we define  $$ m_{p}=\frac{n+S_{p+1}+T_{s}}{2^{a_{p}}} \quad \text { for } 1 \leqslant p \leqslant r \quad \text { and } \quad m_{r+q}=\frac{n+T_{q-1}}{2^{b_{q}}} \quad \text { for } 1 \leqslant q \leqslant s $$  the desired equality holds. It remains to check that every $m_{i}$ is an integer. For $1 \leqslant p \leqslant r$ we have  $$ n+S_{p+1}+T_{s} \equiv n+T_{s} \equiv 0 \quad\left(\bmod 2^{a_{p}}\right) $$  and for $1 \leqslant q \leqslant r$ we have  $$ n+T_{q-1} \equiv n+T_{s} \equiv 0 \quad\left(\bmod 2^{b_{q}}\right) . $$  The desired result follows.


Prove that there exist infinitely many positive integers $n$ such that the largest prime divisor of $n^{4}+n^{2}+1$ is equal to the largest prime divisor of $(n+1)^{4}+(n+1)^{2}+1$.  (Belgium)

Solution: Let $p_{n}$ be the largest prime divisor of $n^{4}+n^{2}+1$ and let $q_{n}$ be the largest prime divisor of $n^{2}+n+1$. Then $p_{n}=q_{n^{2}}$, and from  $$ n^{4}+n^{2}+1=\left(n^{2}+1\right)^{2}-n^{2}=\left(n^{2}-n+1\right)\left(n^{2}+n+1\right)=\left((n-1)^{2}+(n-1)+1\right)\left(n^{2}+n+1\right) $$  it follows that $p_{n}=\max \left\{q_{n}, q_{n-1}\right\}$ for $n \geqslant 2$. Keeping in mind that $n^{2}-n+1$ is odd, we have  $$ \operatorname{gcd}\left(n^{2}+n+1, n^{2}-n+1\right)=\operatorname{gcd}\left(2 n, n^{2}-n+1\right)=\operatorname{gcd}\left(n, n^{2}-n+1\right)=1 . $$  Therefore $q_{n} \neq q_{n-1}$.  To prove the result, it suffices to show that the set  $$ S=\left\{n \in \mathbb{Z}_{\geqslant 2} \mid q_{n}>q_{n-1} \text { and } q_{n}>q_{n+1}\right\} $$  is infinite, since for each $n \in S$ one has  $$ p_{n}=\max \left\{q_{n}, q_{n-1}\right\}=q_{n}=\max \left\{q_{n}, q_{n+1}\right\}=p_{n+1} . $$  Suppose on the contrary that $S$ is finite. Since $q_{2}=7<13=q_{3}$ and $q_{3}=13>7=q_{4}$, the set $S$ is non-empty. Since it is finite, we can consider its largest element, say $m$.  Note that it is impossible that $q_{m}>q_{m+1}>q_{m+2}>\ldots$ because all these numbers are positive integers, so there exists a $k \geqslant m$ such that $q_{k}<q_{k+1}$ (recall that $q_{k} \neq q_{k+1}$ ). Next observe that it is impossible to have $q_{k}<q_{k+1}<q_{k+2}<\ldots$, because $q_{(k+1)^{2}}=p_{k+1}=\max \left\{q_{k}, q_{k+1}\right\}=q_{k+1}$, so let us take the smallest $\ell \geqslant k+1$ such that $q_{\ell}>q_{\ell+1}$. By the minimality of $\ell$ we have $q_{\ell-1}<q_{\ell}$, so $\ell \in S$. Since $\ell \geqslant k+1>k \geqslant m$, this contradicts the maximality of $m$, and hence $S$ is indeed infinite.  Comment. Once the factorization of $n^{4}+n^{2}+1$ is found and the set $S$ is introduced, the problem is mainly about ruling out the case that  $$ q_{k}<q_{k+1}<q_{k+2}<\ldots $$  might hold for some $k \in \mathbb{Z}_{>0}$. In the above solution, this is done by observing $q_{(k+1)^{2}}=\max \left(q_{k}, q_{k+1}\right)$. Alternatively one may notice that (1) implies that $q_{j+2}-q_{j} \geqslant 6$ for $j \geqslant k+1$, since every prime greater than 3 is congruent to -1 or 1 modulo 6 . Then there is some integer $C \geqslant 0$ such that $q_{n} \geqslant 3 n-C$ for all $n \geqslant k$.  Now let the integer $t$ be sufficiently large (e.g. $t=\max \{k+1, C+3\}$ ) and set $p=q_{t-1} \geqslant 2 t$. Then $p \mid(t-1)^{2}+(t-1)+1$ implies that $p \mid(p-t)^{2}+(p-t)+1$, so $p$ and $q_{p-t}$ are prime divisors of $(p-t)^{2}+(p-t)+1$. But $p-t>t-1 \geqslant k$, so $q_{p-t}>q_{t-1}=p$ and $p \cdot q_{p-t}>p^{2}>(p-t)^{2}+(p-t)+1$, a contradiction.


Determine whether there exists an infinite sequence of nonzero digits $a_{1}, a_{2}, a_{3}, \ldots$ and a positive integer $N$ such that for every integer $k>N$, the number $\overline{a_{k} a_{k-1} \ldots a_{1}}$ is a perfect square.  (Iran)

Solution: Assume that $a_{1}, a_{2}, a_{3}, \ldots$ is such a sequence. For each positive integer $k$, let $y_{k}=$ $\overline{a_{k} a_{k-1} \ldots a_{1}}$. By the assumption, for each $k>N$ there exists a positive integer $x_{k}$ such that $y_{k}=x_{k}^{2}$.  I. For every $n$, let $5^{\gamma_{n}}$ be the greatest power of 5 dividing $x_{n}$. Let us show first that $2 \gamma_{n} \geqslant n$ for every positive integer $n>N$.  Assume, to the contrary, that there exists a positive integer $n>N$ such that $2 \gamma_{n}<n$, which yields  $$ y_{n+1}=\overline{a_{n+1} a_{n} \ldots a_{1}}=10^{n} a_{n+1}+\overline{a_{n} a_{n-1} \ldots a_{1}}=10^{n} a_{n+1}+y_{n}=5^{2 \gamma_{n}}\left(2^{n} 5^{n-2 \gamma_{n}} a_{n+1}+\frac{y_{n}}{5^{2 \gamma_{n}}}\right) . $$  Since $5 \nmid y_{n} / 5^{2 \gamma_{n}}$, we obtain $\gamma_{n+1}=\gamma_{n}<n<n+1$. By the same arguments we obtain that $\gamma_{n}=\gamma_{n+1}=\gamma_{n+2}=\ldots$. Denote this common value by $\gamma$.  Now, for each $k \geqslant n$ we have  $$ \left(x_{k+1}-x_{k}\right)\left(x_{k+1}+x_{k}\right)=x_{k+1}^{2}-x_{k}^{2}=y_{k+1}-y_{k}=a_{k+1} \cdot 10^{k} . $$  One of the numbers $x_{k+1}-x_{k}$ and $x_{k+1}+x_{k}$ is not divisible by $5^{\gamma+1}$ since otherwise one would have $5^{\gamma+1} \mid\left(\left(x_{k+1}-x_{k}\right)+\left(x_{k+1}+x_{k}\right)\right)=2 x_{k+1}$. On the other hand, we have $5^{k} \mid\left(x_{k+1}-x_{k}\right)\left(x_{k+1}+x_{k}\right)$, so $5^{k-\gamma}$ divides one of these two factors. Thus we get  $$ 5^{k-\gamma} \leqslant \max \left\{x_{k+1}-x_{k}, x_{k+1}+x_{k}\right\}<2 x_{k+1}=2 \sqrt{y_{k+1}}<2 \cdot 10^{(k+1) / 2} $$  which implies $5^{2 k}<4 \cdot 5^{2 \gamma} \cdot 10^{k+1}$, or $(5 / 2)^{k}<40 \cdot 5^{2 \gamma}$. The last inequality is clearly false for sufficiently large values of $k$. This contradiction shows that $2 \gamma_{n} \geqslant n$ for all $n>N$.  II. Consider now any integer $k>\max \{N / 2,2\}$. Since $2 \gamma_{2 k+1} \geqslant 2 k+1$ and $2 \gamma_{2 k+2} \geqslant 2 k+2$, we have $\gamma_{2 k+1} \geqslant k+1$ and $\gamma_{2 k+2} \geqslant k+1$. So, from $y_{2 k+2}=a_{2 k+2} \cdot 10^{2 k+1}+y_{2 k+1}$ we obtain $5^{2 k+2} \mid y_{2 k+2}-y_{2 k+1}=a_{2 k+2} \cdot 10^{2 k+1}$ and thus $5 \mid a_{2 k+2}$, which implies $a_{2 k+2}=5$. Therefore,  $$ \left(x_{2 k+2}-x_{2 k+1}\right)\left(x_{2 k+2}+x_{2 k+1}\right)=x_{2 k+2}^{2}-x_{2 k+1}^{2}=y_{2 k+2}-y_{2 k+1}=5 \cdot 10^{2 k+1}=2^{2 k+1} \cdot 5^{2 k+2} . $$  Setting $A_{k}=x_{2 k+2} / 5^{k+1}$ and $B_{k}=x_{2 k+1} / 5^{k+1}$, which are integers, we obtain  $$ \left(A_{k}-B_{k}\right)\left(A_{k}+B_{k}\right)=2^{2 k+1} . $$  Both $A_{k}$ and $B_{k}$ are odd, since otherwise $y_{2 k+2}$ or $y_{2 k+1}$ would be a multiple of 10 which is false by $a_{1} \neq 0$; so one of the numbers $A_{k}-B_{k}$ and $A_{k}+B_{k}$ is not divisible by 4 . Therefore (1) yields $A_{k}-B_{k}=2$ and $A_{k}+B_{k}=2^{2 k}$, hence $A_{k}=2^{2 k-1}+1$ and thus  $$ x_{2 k+2}=5^{k+1} A_{k}=10^{k+1} \cdot 2^{k-2}+5^{k+1}>10^{k+1}, $$  since $k \geqslant 2$. This implies that $y_{2 k+2}>10^{2 k+2}$ which contradicts the fact that $y_{2 k+2}$ contains $2 k+2$ digits. The desired result follows.


Solution: Again, we assume that a sequence $a_{1}, a_{2}, a_{3}, \ldots$ satisfies the problem conditions, introduce the numbers $x_{k}$ and $y_{k}$ as in the previous solution, and notice that  $$ y_{k+1}-y_{k}=\left(x_{k+1}-x_{k}\right)\left(x_{k+1}+x_{k}\right)=10^{k} a_{k+1} $$  for all $k>N$. Consider any such $k$. Since $a_{1} \neq 0$, the numbers $x_{k}$ and $x_{k+1}$ are not multiples of 10 , and therefore the numbers $p_{k}=x_{k+1}-x_{k}$ and $q_{k}=x_{k+1}+x_{k}$ cannot be simultaneously multiples of 20 , and hence one of them is not divisible either by 4 or by 5 . In view of (2), this means that the other one is divisible by either $5^{k}$ or by $2^{k-1}$. Notice also that $p_{k}$ and $q_{k}$ have the same parity, so both are even.  On the other hand, we have $x_{k+1}^{2}=x_{k}^{2}+10^{k} a_{k+1} \geqslant x_{k}^{2}+10^{k}>2 x_{k}^{2}$, so $x_{k+1} / x_{k}>\sqrt{2}$, which implies that  $$ 1<\frac{q_{k}}{p_{k}}=1+\frac{2}{x_{k+1} / x_{k}-1}<1+\frac{2}{\sqrt{2}-1}<6 . $$  Thus, if one of the numbers $p_{k}$ and $q_{k}$ is divisible by $5^{k}$, then we have  $$ 10^{k+1}>10^{k} a_{k+1}=p_{k} q_{k} \geqslant \frac{\left(5^{k}\right)^{2}}{6} $$  and hence $(5 / 2)^{k}<60$ which is false for sufficiently large $k$. So, assuming that $k$ is large, we get that $2^{k-1}$ divides one of the numbers $p_{k}$ and $q_{k}$. Hence  $$ \left\{p_{k}, q_{k}\right\}=\left\{2^{k-1} \cdot 5^{r_{k}} b_{k}, 2 \cdot 5^{k-r_{k}} c_{k}\right\} \quad \text { with nonnegative integers } b_{k}, c_{k}, r_{k} \text { such that } b_{k} c_{k}=a_{k+1} \text {. } $$  Moreover, from (3) we get  $$ 6>\frac{2^{k-1} \cdot 5^{r_{k}} b_{k}}{2 \cdot 5^{k-r_{k}} c_{k}} \geqslant \frac{1}{36} \cdot\left(\frac{2}{5}\right)^{k} \cdot 5^{2 r_{k}} \quad \text { and } \quad 6>\frac{2 \cdot 5^{k-r_{k}} c_{k}}{2^{k-1} \cdot 5^{r_{k}} b_{k}} \geqslant \frac{4}{9} \cdot\left(\frac{5}{2}\right)^{k} \cdot 5^{-2 r_{k}} $$  SO  $$ \alpha k+c_{1}<r_{k}<\alpha k+c_{2} \quad \text { for } \alpha=\frac{1}{2} \log _{5}\left(\frac{5}{2}\right)<1 \text { and some constants } c_{2}>c_{1} \text {. } $$  Consequently, for $C=c_{2}-c_{1}+1-\alpha>0$ we have  $$ (k+1)-r_{k+1} \leqslant k-r_{k}+C . $$  Next, we will use the following easy lemma.  Lemma. Let $s$ be a positive integer. Then $5^{s+2^{s}} \equiv 5^{s}\left(\bmod 10^{s}\right)$.  Proof. Euler's theorem gives $5^{2^{s}} \equiv 1\left(\bmod 2^{s}\right)$, so $5^{s+2^{s}}-5^{s}=5^{s}\left(5^{2^{s}}-1\right)$ is divisible by $2^{s}$ and $5^{s}$.  Now, for every large $k$ we have  $$ x_{k+1}=\frac{p_{k}+q_{k}}{2}=5^{r_{k}} \cdot 2^{k-2} b_{k}+5^{k-r_{k}} c_{k} \equiv 5^{k-r_{k}} c_{k} \quad\left(\bmod 10^{r_{k}}\right) $$  since $r_{k} \leqslant k-2$ by $(4)$; hence $y_{k+1} \equiv 5^{2\left(k-r_{k}\right)} c_{k}^{2}\left(\bmod 10^{r_{k}}\right)$. Let us consider some large integer $s$, and choose the minimal $k$ such that $2\left(k-r_{k}\right) \geqslant s+2^{s}$; it exists by (4). Set $d=2\left(k-r_{k}\right)-\left(s+2^{s}\right)$. By (4) we have $2^{s}<2\left(k-r_{k}\right)<\left(\frac{2}{\alpha}-2\right) r_{k}-\frac{2 c_{1}}{\alpha}$; if $s$ is large this implies $r_{k}>s$, so (6) also holds modulo $10^{s}$. Then (6) and the lemma give  $$ y_{k+1} \equiv 5^{2\left(k-r_{k}\right)} c_{k}^{2}=5^{s+2^{s}} \cdot 5^{d} c_{k}^{2} \equiv 5^{s} \cdot 5^{d} c_{k}^{2} \quad\left(\bmod 10^{s}\right) . $$  By (5) and the minimality of $k$ we have $d \leqslant 2 C$, so $5^{d} c_{k}^{2} \leqslant 5^{2 C} \cdot 81=D$. Using $5^{4}<10^{3}$ we obtain  $$ 5^{s} \cdot 5^{d} c_{k}^{2}<10^{3 s / 4} D<10^{s-1} $$  for sufficiently large $s$. This, together with (7), shows that the sth digit from the right in $y_{k+1}$, which is $a_{s}$, is zero. This contradicts the problem condition.


Fix an integer $k \geqslant 2$. Two players, called Ana and Banana, play the following game of numbers: Initially, some integer $n \geqslant k$ gets written on the blackboard. Then they take moves in turn, with Ana beginning. A player making a move erases the number $m$ just written on the blackboard and replaces it by some number $m^{\prime}$ with $k \leqslant m^{\prime}<m$ that is coprime to $m$. The first player who cannot move anymore loses.  An integer $n \geqslant k$ is called good if Banana has a winning strategy when the initial number is $n$, and bad otherwise.  Consider two integers $n, n^{\prime} \geqslant k$ with the property that each prime number $p \leqslant k$ divides $n$ if and only if it divides $n^{\prime}$. Prove that either both $n$ and $n^{\prime}$ are good or both are bad.  (Italy)

Solution: Let us first observe that the number appearing on the blackboard decreases after every move; so the game necessarily ends after at most $n$ steps, and consequently there always has to be some player possessing a winning strategy. So if some $n \geqslant k$ is bad, then Ana has a winning strategy in the game with starting number $n$.  More precisely, if $n \geqslant k$ is such that there is a good integer $m$ with $n>m \geqslant k$ and $\operatorname{gcd}(m, n)=1$, then $n$ itself is bad, for Ana has the following winning strategy in the game with initial number $n$ : She proceeds by first playing $m$ and then using Banana's strategy for the game with starting number $m$.  Otherwise, if some integer $n \geqslant k$ has the property that every integer $m$ with $n>m \geqslant k$ and $\operatorname{gcd}(m, n)=1$ is bad, then $n$ is good. Indeed, if Ana can make a first move at all in the game with initial number $n$, then she leaves it in a position where the first player has a winning strategy, so that Banana can defeat her.  In particular, this implies that any two good numbers have a non-trivial common divisor. Also, $k$ itself is good.  For brevity, we say that $n \longrightarrow x$ is a move if $n$ and $x$ are two coprime integers with $n>x \geqslant k$.  Claim 1. If $n$ is good and $n^{\prime}$ is a multiple of $n$, then $n^{\prime}$ is also good.  Proof. If $n^{\prime}$ were bad, there would have to be some move $n^{\prime} \longrightarrow x$, where $x$ is good. As $n^{\prime}$ is a multiple of $n$ this implies that the two good numbers $n$ and $x$ are coprime, which is absurd.  Claim 2. If $r$ and $s$ denote two positive integers for which $r s \geqslant k$ is bad, then $r^{2} s$ is also bad.  Proof. Since $r s$ is bad, there is a move $r s \longrightarrow x$ for some good $x$. Evidently $x$ is coprime to $r^{2} s$ as well, and hence the move $r^{2} s \longrightarrow x$ shows that $r^{2} s$ is indeed bad.  Claim 3. If $p>k$ is prime and $n \geqslant k$ is bad, then $n p$ is also bad.  Proof. Otherwise we choose a counterexample with $n$ being as small as possible. In particular, $n p$ is good. Since $n$ is bad, there is a move $n \longrightarrow x$ for some good $x$. Now $n p \longrightarrow x$ cannot be a valid move, which tells us that $x$ has to be divisible by $p$. So we can write $x=p^{r} y$, where $r$ and $y$ denote some positive integers, the latter of which is not divisible by $p$.  Note that $y=1$ is impossible, for then we would have $x=p^{r}$ and the move $x \longrightarrow k$ would establish that $x$ is bad. In view of this, there is a least power $y^{\alpha}$ of $y$ that is at least as large as $k$. Since the numbers $n p$ and $y^{\alpha}$ are coprime and the former is good, the latter has to be bad. Moreover, the minimality of $\alpha$ implies $y^{\alpha}<k y<p y=\frac{x}{p^{r-1}}<\frac{n}{p^{r-1}}$. So $p^{r-1} \cdot y^{\alpha}<n$ and consequently all the numbers $y^{\alpha}, p y^{\alpha}, \ldots, p^{r} \cdot y^{\alpha}=p\left(p^{r-1} \cdot y^{\alpha}\right)$ are bad due to the minimal choice of $n$. But now by Claim 1 the divisor $x$ of $p^{r} \cdot y^{\alpha}$ cannot be good, whereby we have reached a contradiction that proves Claim 3.  We now deduce the statement of the problem from these three claims. To this end, we call two integers $a, b \geqslant k$ similar if they are divisible by the same prime numbers not exceeding $k$. We are to prove that if $a$ and $b$ are similar, then either both of them are good or both are bad. As in this case the product $a b$ is similar to both $a$ and $b$, it suffices to show the following: if $c \geqslant k$ is similar to some of its multiples $d$, then either both $c$ and $d$ are good or both are bad.  Assuming that this is not true in general, we choose a counterexample $\left(c_{0}, d_{0}\right)$ with $d_{0}$ being as small as possible. By Claim 1, $c_{0}$ is bad whilst $d_{0}$ is good. Plainly $d_{0}$ is strictly greater than $c_{0}$ and hence the quotient $\frac{d_{0}}{c_{0}}$ has some prime factor $p$. Clearly $p$ divides $d_{0}$. If $p \leqslant k$, then $p$ divides $c_{0}$ as well due to the similarity, and hence $d_{0}$ is actually divisible by $p^{2}$. So $\frac{d_{0}}{p}$ is good by the contrapositive of Claim 2. Since $c_{0} \left\lvert\, \frac{d_{0}}{p}\right.$, the pair $\left(c_{0}, \frac{d_{0}}{p}\right)$ contradicts the supposed minimality of $d_{0}$. This proves $p>k$, but now we get the same contradiction using Claim 3 instead of Claim 2 . Thereby the problem is solved.


Solution: We use the same analysis of the game of numbers as in the first five paragraphs of the first solution. Let us call a prime number $p$ small in case $p \leqslant k$ and big otherwise. We again call two integers similar if their sets of small prime factors coincide.  Claim 4. For each integer $b \geqslant k$ having some small prime factor, there exists an integer $x$ similar to it with $b \geqslant x \geqslant k$ and having no big prime factors.  Proof. Unless $b$ has a big prime factor we may simply choose $x=b$. Now let $p$ and $q$ denote a small and a big prime factor of $b$, respectively. Let $a$ be the product of all small prime factors of $b$. Further define $n$ to be the least non-negative integer for which the number $x=p^{n} a$ is at least as large as $k$. It suffices to show that $b>x$. This is clear in case $n=0$, so let us assume $n>0$ from now on. Then we have $x<p k$ due to the minimality of $n, p \leqslant a$ because $p$ divides $a$ by construction, and $k<q$. Therefore $x<a q$ and, as the right hand side is a product of distinct prime factors of $b$, this implies indeed $x<b$.  Let us now assume that there is a pair $(a, b)$ of similar numbers such that $a$ is bad and $b$ is good. Take such a pair with $\max (a, b)$ being as small as possible. Since $a$ is bad, there exists a move $a \longrightarrow r$ for some good $r$. Since the numbers $k$ and $r$ are both good, they have a common prime factor, which necessarily has to be small. Thus Claim 4 is applicable to $r$, which yields an integer $r^{\prime}$ similar to $r$ containing small prime factors only and satisfying $r \geqslant r^{\prime} \geqslant k$. Since $\max \left(r, r^{\prime}\right)=r<a \leqslant \max (a, b)$ the number $r^{\prime}$ is also good. Now let $p$ denote a common prime factor of the good numbers $r^{\prime}$ and $b$. By our construction of $r^{\prime}$, this prime is small and due to the similarities it consequently divides $a$ and $r$, contrary to $a \longrightarrow r$ being a move. Thereby the problem is solved.  Comment 1. Having reached Claim 4 of Solution 2, there are various other ways to proceed. For instance, one may directly obtain the following fact, which seems to be interesting in its own right:  Claim 5. Any two good numbers have a common small prime factor.  Proof. Otherwise there exists a pair $\left(b, b^{\prime}\right)$ of good numbers with $b^{\prime} \geqslant b \geqslant k$ all of whose common prime factors are big. Choose such a pair with $b^{\prime}$ being as small as possible. Since $b$ and $k$ are both good, there has to be a common prime factor $p$ of $b$ and $k$. Evidently $p$ is small and thus it cannot divide $b^{\prime}$, which in turn tells us $b^{\prime}>b$. Applying Claim 4 to $b$ we get an integer $x$ with $b \geqslant x \geqslant k$ that is similar to $b$ and has no big prime divisors at all. By our assumption, $b^{\prime}$ and $x$ are coprime, and as $b^{\prime}$ is good this implies that $x$ is bad. Consequently there has to be some move $x \longrightarrow b^{*}$ such that $b^{*}$ is good. But now all the small prime factors of $b$ also appear in $x$ and thus they cannot divide $b^{*}$. Therefore the pair $\left(b^{*}, b\right)$ contradicts the supposed minimality of $b^{\prime}$.  From that point, it is easy to complete the solution: assume that there are two similar integers $a$ and $b$ such that $a$ is bad and $b$ is good. Since $a$ is bad, there is a move $a \longrightarrow b^{\prime}$ for some good $b^{\prime}$. By Claim 5, there is a small prime $p$ dividing $b$ and $b^{\prime}$. Due to the similarity of $a$ and $b$, the prime $p$ has to divide $a$ as well, but this contradicts the fact that $a \longrightarrow b^{\prime}$ is a valid move. Thereby the problem is solved.  Comment 2. There are infinitely many good numbers, e.g. all multiples of $k$. The increasing sequence $b_{0}, b_{1}, \ldots$, of all good numbers may be constructed recursively as follows:  - Start with $b_{0}=k$. - If $b_{n}$ has just been defined for some $n \geqslant 0$, then $b_{n+1}$ is the smallest number $b>b_{n}$ that is coprime to none of $b_{0}, \ldots, b_{n}$.  This construction can be used to determine the set of good numbers for any specific $k$ as explained in the next comment. It is already clear that if $k=p^{\alpha}$ is a prime power, then a number $b \geqslant k$ is good if and only if it is divisible by $p$.  Comment 3. Let $P>1$ denote the product of all small prime numbers. Then any two integers $a, b \geqslant k$ that are congruent modulo $P$ are similar. Thus the infinite word $W_{k}=\left(X_{k}, X_{k+1}, \ldots\right)$ defined by  $$ X_{i}= \begin{cases}A & \text { if } i \text { is bad } \\ B & \text { if } i \text { is good }\end{cases} $$  for all $i \geqslant k$ is periodic and the length of its period divides $P$. As the prime power example shows, the true period can sometimes be much smaller than $P$. On the other hand, there are cases where the period is rather large; e.g., if $k=15$, the sequence of good numbers begins with 15,18,20,24,30,36,40,42, 45 and the period of $W_{15}$ is 30 .  Comment 4. The original proposal contained two questions about the game of numbers, namely $(a)$ to show that if two numbers have the same prime factors then either both are good or both are bad, and (b) to show that the word $W_{k}$ introduced in the previous comment is indeed periodic. The Problem Selection Committee thinks that the above version of the problem is somewhat easier, even though it demands to prove a stronger result.


Determine all functions $f: \mathbb{Q} \longrightarrow \mathbb{Z}$ satisfying  $$ f\left(\frac{f(x)+a}{b}\right)=f\left(\frac{x+a}{b}\right) $$  for all $x \in \mathbb{Q}, a \in \mathbb{Z}$, and $b \in \mathbb{Z}_{>0}$. (Here, $\mathbb{Z}_{>0}$ denotes the set of positive integers.)  (Israel)

Solution: I. We start by verifying that these functions do indeed satisfy (1). This is clear for all constant functions. Now consider any triple $(x, a, b) \in \mathbb{Q} \times \mathbb{Z} \times \mathbb{Z}_{>0}$ and set  $$ q=\left\lfloor\frac{x+a}{b}\right\rfloor . $$  This means that $q$ is an integer and $b q \leqslant x+a<b(q+1)$. It follows that $b q \leqslant\lfloor x\rfloor+a<b(q+1)$ holds as well, and thus we have  $$ \left\lfloor\frac{\lfloor x\rfloor+a}{b}\right\rfloor=\left\lfloor\frac{x+a}{b}\right\rfloor, $$  meaning that the floor function does indeed satisfy (1). One can check similarly that the ceiling function has the same property.  II. Let us now suppose conversely that the function $f: \mathbb{Q} \longrightarrow \mathbb{Z}$ satisfies (1) for all $(x, a, b) \in$ $\mathbb{Q} \times \mathbb{Z} \times \mathbb{Z}_{>0}$. According to the behaviour of the restriction of $f$ to the integers we distinguish two cases.  Case 1: There is some $m \in \mathbb{Z}$ such that $f(m) \neq m$.  Write $f(m)=C$ and let $\eta \in\{-1,+1\}$ and $b$ denote the sign and absolute value of $f(m)-m$, respectively. Given any integer $r$, we may plug the triple $(m, r b-C, b)$ into (1), thus getting $f(r)=f(r-\eta)$. Starting with $m$ and using induction in both directions, we deduce from this that the equation $f(r)=C$ holds for all integers $r$. Now any rational number $y$ can be written in the form $y=\frac{p}{q}$ with $(p, q) \in \mathbb{Z} \times \mathbb{Z}_{>0}$, and substituting $(C-p, p-C, q)$ into (1) we get $f(y)=f(0)=C$. Thus $f$ is the constant function whose value is always $C$.  Case 2: One has $f(m)=m$ for all integers $m$.  Note that now the special case $b=1$ of (1) takes a particularly simple form, namely  $$ f(x)+a=f(x+a) \quad \text { for all }(x, a) \in \mathbb{Q} \times \mathbb{Z} $$  Defining $f\left(\frac{1}{2}\right)=\omega$ we proceed in three steps.  Step $A$. We show that $\omega \in\{0,1\}$.  If $\omega \leqslant 0$, we may plug $\left(\frac{1}{2},-\omega, 1-2 \omega\right)$ into (1), obtaining $0=f(0)=f\left(\frac{1}{2}\right)=\omega$. In the contrary case $\omega \geqslant 1$ we argue similarly using the triple $\left(\frac{1}{2}, \omega-1,2 \omega-1\right)$.  Step B. We show that $f(x)=\omega$ for all rational numbers $x$ with $0<x<1$.  Assume that this fails and pick some rational number $\frac{a}{b} \in(0,1)$ with minimal $b$ such that $f\left(\frac{a}{b}\right) \neq \omega$. Obviously, $\operatorname{gcd}(a, b)=1$ and $b \geqslant 2$. If $b$ is even, then $a$ has to be odd and we can substitute $\left(\frac{1}{2}, \frac{a-1}{2}, \frac{b}{2}\right)$ into (1), which yields  $$ f\left(\frac{\omega+(a-1) / 2}{b / 2}\right)=f\left(\frac{a}{b}\right) \neq \omega . $$  Recall that $0 \leqslant(a-1) / 2<b / 2$. Thus, in both cases $\omega=0$ and $\omega=1$, the left-hand part of (3) equals $\omega$ either by the minimality of $b$, or by $f(\omega)=\omega$. A contradiction.  Thus $b$ has to be odd, so $b=2 k+1$ for some $k \geqslant 1$. Applying $(1)$ to $\left(\frac{1}{2}, k, b\right)$ we get  $$ f\left(\frac{\omega+k}{b}\right)=f\left(\frac{1}{2}\right)=\omega . $$  Since $a$ and $b$ are coprime, there exist integers $r \in\{1,2, \ldots, b\}$ and $m$ such that $r a-m b=k+\omega$. Note that we actually have $1 \leqslant r<b$, since the right hand side is not a multiple of $b$. If $m$ is negative, then we have $r a-m b>b \geqslant k+\omega$, which is absurd. Similarly, $m \geqslant r$ leads to $r a-m b<b r-b r=0$, which is likewise impossible; so we must have $0 \leqslant m \leqslant r-1$.  We finally substitute $\left(\frac{k+\omega}{b}, m, r\right)$ into (1) and use (4) to learn  $$ f\left(\frac{\omega+m}{r}\right)=f\left(\frac{a}{b}\right) \neq \omega $$  But as above one may see that the left hand side has to equal $\omega$ due to the minimality of $b$. This contradiction concludes our step B.  Step C. Now notice that if $\omega=0$, then $f(x)=\lfloor x\rfloor$ holds for all rational $x$ with $0 \leqslant x<1$ and hence by (2) this even holds for all rational numbers $x$. Similarly, if $\omega=1$, then $f(x)=\lceil x\rceil$ holds for all $x \in \mathbb{Q}$. Thereby the problem is solved.  Comment 1. An alternative treatment of Steps B and C from the second case, due to the proposer, proceeds as follows. Let square brackets indicate the floor function in case $\omega=0$ and the ceiling function if $\omega=1$. We are to prove that $f(x)=[x]$ holds for all $x \in \mathbb{Q}$, and because of Step A and (2) we already know this in case $2 x \in \mathbb{Z}$. Applying (1) to $(2 x, 0,2)$ we get  $$ f(x)=f\left(\frac{f(2 x)}{2}\right) $$  and by the previous observation this yields  $$ f(x)=\left[\frac{f(2 x)}{2}\right] \quad \text { for all } x \in \mathbb{Q} $$  An easy induction now shows  $$ f(x)=\left[\frac{f\left(2^{n} x\right)}{2^{n}}\right] \quad \text { for all }(x, n) \in \mathbb{Q} \times \mathbb{Z}_{>0} $$  Now suppose first that $x$ is not an integer but can be written in the form $\frac{p}{q}$ with $p \in \mathbb{Z}$ and $q \in \mathbb{Z}_{>0}$ both being odd. Let $d$ denote the multiplicative order of 2 modulo $q$ and let $m$ be any large integer. Plugging $n=d m$ into (6) and using (2) we get  $$ f(x)=\left[\frac{f\left(2^{d m} x\right)}{2^{d m}}\right]=\left[\frac{f(x)+\left(2^{d m}-1\right) x}{2^{d m}}\right]=\left[x+\frac{f(x)-x}{2^{d m}}\right] . $$  Since $x$ is not an integer, the square bracket function is continuous at $x$; hence as $m$ tends to infinity the above fomula gives $f(x)=[x]$. To complete the argument we just need to observe that if some $y \in \mathbb{Q}$ satisfies $f(y)=[y]$, then (5) yields $f\left(\frac{y}{2}\right)=f\left(\frac{[y]}{2}\right)=\left[\frac{[y]}{2}\right]=\left[\frac{y}{2}\right]$.


Solution: Here we just give another argument for the second case of the above solution. Again we use equation (2). It follows that the set $S$ of all zeros of $f$ contains for each $x \in \mathbb{Q}$ exactly one term from the infinite sequence $\ldots, x-2, x-1, x, x+1, x+2, \ldots$.  Next we claim that  $$ \text { if }(p, q) \in \mathbb{Z} \times \mathbb{Z}_{>0} \text { and } \frac{p}{q} \in S \text {, then } \frac{p}{q+1} \in S \text { holds as well. } $$  To see this we just plug $\left(\frac{p}{q}, p, q+1\right)$ into (1), thus getting $f\left(\frac{p}{q+1}\right)=f\left(\frac{p}{q}\right)=0$.  From this we get that  $$ \text { if } x, y \in \mathbb{Q}, x>y>0 \text {, and } x \in S \text {, then } y \in S \text {. } $$  Indeed, if we write $x=\frac{p}{q}$ and $y=\frac{r}{s}$ with $p, q, r, s \in \mathbb{Z}_{>0}$, then $p s>q r$ and (7) tells us  $$ 0=f\left(\frac{p}{q}\right)=f\left(\frac{p r}{q r}\right)=f\left(\frac{p r}{q r+1}\right)=\ldots=f\left(\frac{p r}{p s}\right)=f\left(\frac{r}{s}\right) $$  Essentially the same argument also establishes that  $$ \text { if } x, y \in \mathbb{Q}, x<y<0 \text {, and } x \in S \text {, then } y \in S \text {. } $$  From (8) and (9) we get $0 \in S \subseteq(-1,+1)$ and hence the real number $\alpha=\sup (S)$ exists and satisfies $0 \leqslant \alpha \leqslant 1$.  Let us assume that we actually had $0<\alpha<1$. Note that $f(x)=0$ if $x \in(0, \alpha) \cap \mathbb{Q}$ by (8), and $f(x)=1$ if $x \in(\alpha, 1) \cap \mathbb{Q}$ by (9) and (2). Let $K$ denote the unique positive integer satisfying $K \alpha<1 \leqslant(K+1) \alpha$. The first of these two inequalities entails $\alpha<\frac{1+\alpha}{K+1}$, and thus there is a rational number $x \in\left(\alpha, \frac{1+\alpha}{K+1}\right)$. Setting $y=(K+1) x-1$ and substituting $(y, 1, K+1)$ into (1) we learn  $$ f\left(\frac{f(y)+1}{K+1}\right)=f\left(\frac{y+1}{K+1}\right)=f(x) . $$  Since $\alpha<x<1$ and $0<y<\alpha$, this simplifies to  $$ f\left(\frac{1}{K+1}\right)=1 $$  But, as $0<\frac{1}{K+1} \leqslant \alpha$, this is only possible if $\alpha=\frac{1}{K+1}$ and $f(\alpha)=1$. From this, however, we get the contradiction  $$ 0=f\left(\frac{1}{(K+1)^{2}}\right)=f\left(\frac{\alpha+0}{K+1}\right)=f\left(\frac{f(\alpha)+0}{K+1}\right)=f(\alpha)=1 $$  Thus our assumption $0<\alpha<1$ has turned out to be wrong and it follows that $\alpha \in\{0,1\}$. If $\alpha=0$, then we have $S \subseteq(-1,0]$, whence $S=(-1,0] \cap \mathbb{Q}$, which in turn yields $f(x)=\lceil x\rceil$ for all $x \in \mathbb{Q}$ due to (2). Similarly, $\alpha=1$ entails $S=[0,1) \cap \mathbb{Q}$ and $f(x)=\lfloor x\rfloor$ for all $x \in \mathbb{Q}$. Thereby the solution is complete.  Comment 2. It seems that all solutions to this problems involve some case distinction separating the constant solutions from the unbounded ones, though the "descriptions" of the cases may be different depending on the work that has been done at the beginning of the solution. For instance, these two cases can also be " $f$ is periodic on the integers" and " $f$ is not periodic on the integers". The case leading to the unbounded solutions appears to be the harder one.  In most approaches, the cases leading to the two functions $x \longmapsto\lfloor x\rfloor$ and $x \longmapsto\lceil x\rceil$ can easily be treated parallelly, but sometimes it may be useful to know that there is some symmetry in the problem interchanging these two functions. Namely, if a function $f: \mathbb{Q} \longrightarrow \mathbb{Z}$ satisfies (1), then so does the function $g: \mathbb{Q} \longrightarrow \mathbb{Z}$ defined by $g(x)=-f(-x)$ for all $x \in \mathbb{Q}$. For that reason, we could have restricted our attention to the case $\omega=0$ in the first solution and, once $\alpha \in\{0,1\}$ had been obtained, to the case $\alpha=0$ in the second solution.


Let $\nu$ be an irrational positive number, and let $m$ be a positive integer. A pair $(a, b)$ of positive integers is called good if  $$ a\lceil b \nu\rceil-b\lfloor a \nu\rfloor=m . $$  A good pair $(a, b)$ is called excellent if neither of the pairs $(a-b, b)$ and $(a, b-a)$ is good. (As usual, by $\lfloor x\rfloor$ and $\lceil x\rceil$ we denote the integer numbers such that $x-1<\lfloor x\rfloor \leqslant x$ and $x \leqslant\lceil x\rceil<x+1$.)  Prove that the number of excellent pairs is equal to the sum of the positive divisors of $m$.

Solution: For positive integers $a$ and $b$, let us denote  $$ f(a, b)=a\lceil b \nu\rceil-b\lfloor a \nu\rfloor . $$  We will deal with various values of $m$; thus it is convenient to say that a pair $(a, b)$ is $m$-good or $m$-excellent if the corresponding conditions are satisfied.  To start, let us investigate how the values $f(a+b, b)$ and $f(a, b+a)$ are related to $f(a, b)$. If $\{a \nu\}+\{b \nu\}<1$, then we have $\lfloor(a+b) \nu\rfloor=\lfloor a \nu\rfloor+\lfloor b \nu\rfloor$ and $\lceil(a+b) \nu\rceil=\lceil a \nu\rceil+\lceil b \nu\rceil-1$, so  $$ f(a+b, b)=(a+b)\lceil b \nu\rceil-b(\lfloor a \nu\rfloor+\lfloor b \nu\rfloor)=f(a, b)+b(\lceil b \nu\rceil-\lfloor b \nu\rfloor)=f(a, b)+b $$  and  $$ f(a, b+a)=a(\lceil b \nu\rceil+\lceil a \nu\rceil-1)-(b+a)\lfloor a \nu\rfloor=f(a, b)+a(\lceil a \nu\rceil-1-\lfloor a \nu\rfloor)=f(a, b) . $$  Similarly, if $\{a \nu\}+\{b \nu\} \geqslant 1$ then one obtains  $$ f(a+b, b)=f(a, b) \text { and } f(a, b+a)=f(a, b)+a \text {. } $$  So, in both cases one of the numbers $f(a+b, a)$ and $f(a, b+a)$ is equal to $f(a, b)$ while the other is greater than $f(a, b)$ by one of $a$ and $b$. Thus, exactly one of the pairs $(a+b, b)$ and $(a, b+a)$ is excellent (for an appropriate value of $m$ ).  Now let us say that the pairs $(a+b, b)$ and $(a, b+a)$ are the children of the pair $(a, b)$, while this pair is their parent. Next, if a pair $(c, d)$ can be obtained from $(a, b)$ by several passings from a parent to a child, we will say that $(c, d)$ is a descendant of $(a, b)$, while $(a, b)$ is an ancestor of $(c, d)$ (a pair is neither an ancestor nor a descendant of itself). Thus each pair $(a, b)$ has two children, it has a unique parent if $a \neq b$, and no parents otherwise. Therefore, each pair of distinct positive integers has a unique ancestor of the form $(a, a)$; our aim is now to find how many $m$-excellent descendants each such pair has.  Notice now that if a pair $(a, b)$ is $m$-excellent then $\min \{a, b\} \leqslant m$. Indeed, if $a=b$ then $f(a, a)=a=m$, so the statement is valid. Otherwise, the pair $(a, b)$ is a child of some pair $\left(a^{\prime}, b^{\prime}\right)$. If $b=b^{\prime}$ and $a=a^{\prime}+b^{\prime}$, then we should have $m=f(a, b)=f\left(a^{\prime}, b^{\prime}\right)+b^{\prime}$, so $b=b^{\prime}=m-f\left(a^{\prime}, b^{\prime}\right)<m$. Similarly, if $a=a^{\prime}$ and $b=b^{\prime}+a^{\prime}$ then $a<m$.  Let us consider the set $S_{m}$ of all pairs $(a, b)$ such that $f(a, b) \leqslant m$ and $\min \{a, b\} \leqslant m$. Then all the ancestors of the elements in $S_{m}$ are again in $S_{m}$, and each element in $S_{m}$ either is of the form $(a, a)$ with $a \leqslant m$, or has a unique ancestor of this form. From the arguments above we see that all $m$-excellent pairs lie in $S_{m}$.  We claim now that the set $S_{m}$ is finite. Indeed, assume, for instance, that it contains infinitely many pairs $(c, d)$ with $d>2 m$. Such a pair is necessarily a child of $(c, d-c)$, and thus a descendant of some pair $\left(c, d^{\prime}\right)$ with $m<d^{\prime} \leqslant 2 m$. Therefore, one of the pairs $(a, b) \in S_{m}$ with $m<b \leqslant 2 m$ has infinitely many descendants in $S_{m}$, and all these descendants have the form $(a, b+k a)$ with $k$ a positive integer. Since $f(a, b+k a)$ does not decrease as $k$ grows, it becomes constant for $k \geqslant k_{0}$, where $k_{0}$ is some positive integer. This means that $\{a \nu\}+\{(b+k a) \nu\}<1$ for all $k \geqslant k_{0}$. But this yields $1>\{(b+k a) \nu\}=\left\{\left(b+k_{0} a\right) \nu\right\}+\left(k-k_{0}\right)\{a \nu\}$ for all $k>k_{0}$, which is absurd.  Similarly, one can prove that $S_{m}$ contains finitely many pairs $(c, d)$ with $c>2 m$, thus finitely many elements at all.  We are now prepared for proving the following crucial lemma.  Lemma. Consider any pair $(a, b)$ with $f(a, b) \neq m$. Then the number $g(a, b)$ of its $m$-excellent descendants is equal to the number $h(a, b)$ of ways to represent the number $t=m-f(a, b)$ as $t=k a+\ell b$ with $k$ and $\ell$ being some nonnegative integers.  Proof. We proceed by induction on the number $N$ of descendants of $(a, b)$ in $S_{m}$. If $N=0$ then clearly $g(a, b)=0$. Assume that $h(a, b)>0$; without loss of generality, we have $a \leqslant b$. Then, clearly, $m-f(a, b) \geqslant a$, so $f(a, b+a) \leqslant f(a, b)+a \leqslant m$ and $a \leqslant m$, hence $(a, b+a) \in S_{m}$ which is impossible. Thus in the base case we have $g(a, b)=h(a, b)=0$, as desired.  Now let $N>0$. Assume that $f(a+b, b)=f(a, b)+b$ and $f(a, b+a)=f(a, b)$ (the other case is similar). If $f(a, b)+b \neq m$, then by the induction hypothesis we have  $$ g(a, b)=g(a+b, b)+g(a, b+a)=h(a+b, b)+h(a, b+a) $$  Notice that both pairs $(a+b, b)$ and $(a, b+a)$ are descendants of $(a, b)$ and thus each of them has strictly less descendants in $S_{m}$ than $(a, b)$ does.  Next, each one of the $h(a+b, b)$ representations of $m-f(a+b, b)=m-b-f(a, b)$ as the sum $k^{\prime}(a+b)+\ell^{\prime} b$ provides the representation $m-f(a, b)=k a+\ell b$ with $k=k^{\prime}<k^{\prime}+\ell^{\prime}+1=\ell$. Similarly, each one of the $h(a, b+a)$ representations of $m-f(a, b+a)=m-f(a, b)$ as the sum $k^{\prime} a+\ell^{\prime}(b+a)$ provides the representation $m-f(a, b)=k a+\ell b$ with $k=k^{\prime}+\ell^{\prime} \geqslant \ell^{\prime}=\ell$. This correspondence is obviously bijective, so  $$ h(a, b)=h(a+b, b)+h(a, b+a)=g(a, b) $$  as required.  Finally, if $f(a, b)+b=m$ then $(a+b, b)$ is $m$-excellent, so $g(a, b)=1+g(a, b+a)=1+h(a, b+a)$ by the induction hypothesis. On the other hand, the number $m-f(a, b)=b$ has a representation $0 \cdot a+1 \cdot b$ and sometimes one more representation as $k a+0 \cdot b$; this last representation exists simultaneously with the representation $m-f(a, b+a)=k a+0 \cdot(b+a)$, so $h(a, b)=1+h(a, b+a)$ as well. Thus in this case the step is also proved.  Now it is easy to finish the solution. There exists a unique $m$-excellent pair of the form $(a, a)$, and each other $m$-excellent pair $(a, b)$ has a unique ancestor of the form $(x, x)$ with $x<m$. By the lemma, for every $x<m$ the number of its $m$-excellent descendants is $h(x, x)$, which is the number of ways to represent $m-f(x, x)=m-x$ as $k x+\ell x$ (with nonnegative integer $k$ and $\ell$ ). This number is 0 if $x \nmid m$, and $m / x$ otherwise. So the total number of excellent pairs is  $$ 1+\sum_{x \mid m, x<m} \frac{m}{x}=1+\sum_{d \mid m, d>1} d=\sum_{d \mid m} d $$  as required.  Comment. Let us present a sketch of an outline of a different solution. The plan is to check that the number of excellent pairs does not depend on the (irrational) number $\nu$, and to find this number for some appropriate value of $\nu$. For that, we first introduce some geometrical language. We deal only with the excellent pairs $(a, b)$ with $a \neq b$.  Part I. Given an irrational positive $\nu$, for every positive integer $n$ we introduce two integral points $F_{\nu}(n)=$ $(n,\lfloor n \nu\rfloor)$ and $C_{\nu}(n)=(n,\lceil n \nu\rceil)$ on the coordinate plane $O x y$. Then $(*)$ reads as $\left[O F_{\nu}(a) C_{\nu}(b)\right]=m / 2$; here $[\cdot]$ stands for the signed area. Next, we rewrite in these terms the condition on a pair $(a, b)$ to be excellent. Let $\ell_{\nu}, \ell_{\nu}^{+}$, and $\ell_{\nu}^{-}$be the lines determined by the equations $y=\nu x, y=\nu x+1$, and $y=\nu x-1$, respectively.  a). Firstly, we deal with all excellent pairs $(a, b)$ with $a<b$. Given some value of $a$, all the points $C$ such that $\left[O F_{\nu}(a) C\right]=m / 2$ lie on some line $f_{\nu}(a)$; if there exist any good pairs $(a, b)$ at all, this line has to contain at least one integral point, which happens exactly when $\operatorname{gcd}(a,\lfloor a \nu\rfloor) \mid m$.  Let $P_{\nu}(a)$ be the point of intersection of $\ell_{\nu}^{+}$and $f_{\nu}(a)$, and let $p_{\nu}(a)$ be its abscissa; notice that $p_{\nu}(a)$ is irrational if it is nonzero. Now, if $(a, b)$ is good, then the point $C_{\nu}(b)$ lies on $f_{\nu}(a)$, which means that the point of $f_{\nu}(a)$ with abscissa $b$ lies between $\ell_{\nu}$ and $\ell_{\nu}^{+}$and is integral. If in addition the pair $(a, b-a)$ is not good, then the point of $f_{\nu}(a)$ with abscissa $b-a$ lies above $\ell_{\nu}^{+}$(see Fig. 1). Thus, the pair $(a, b)$ with $b>a$ is excellent exactly when $p_{\nu}(a)$ lies between $b-a$ and $b$, and the point of $f_{\nu}(a)$ with abscissa $b$ is integral (which means that this point is $C_{\nu}(b)$ ).  Notice now that, if $p_{\nu}(a)>a$, then the number of excellent pairs of the form $(a, b)$ (with $b>a$ ) is $\operatorname{gcd}(a,\lfloor a \nu\rfloor)$.  ![](https://cdn.mathpix.com/cropped/2024_04_17_e0914cb4f8055c731538g-67.jpg?height=396&width=422&top_left_y=1274&top_left_x=556)  Figure 1  ![](https://cdn.mathpix.com/cropped/2024_04_17_e0914cb4f8055c731538g-67.jpg?height=431&width=442&top_left_y=1254&top_left_x=1123)  Figure 2  b). Analogously, considering the pairs $(a, b)$ with $a>b$, we fix the value of $b$, introduce the line $c_{\nu}(b)$ containing all the points $F$ with $\left[O F C_{\nu}(b)\right]=m / 2$, assume that this line contains an integral point (which means $\operatorname{gcd}(b,\lceil b \nu\rceil) \mid m$ ), and denote the common point of $c_{\nu}(b)$ and $\ell_{\nu}^{-}$by $Q_{\nu}(b)$, its abscissa being $q_{\nu}(b)$. Similarly to the previous case, we obtain that the pair $(a, b)$ is excellent exactly when $q_{\nu}(a)$ lies between $a-b$ and $a$, and the point of $c_{\nu}(b)$ with abscissa $a$ is integral (see Fig. 2). Again, if $q_{\nu}(b)>b$, then the number of excellent pairs of the form $(a, b)$ (with $a>b)$ is $\operatorname{gcd}(b,\lceil b \nu\rceil)$.  Part II, sketchy. Having obtained such a description, one may check how the number of excellent pairs changes as $\nu$ grows. (Having done that, one may find this number for one appropriate value of $\nu$; for instance, it is relatively easy to make this calculation for $\nu \in\left(1,1+\frac{1}{m}\right)$.)  Consider, for the initial value of $\nu$, some excellent pair $(a, t)$ with $a>t$. As $\nu$ grows, this pair eventually stops being excellent; this happens when the point $Q_{\nu}(t)$ passes through $F_{\nu}(a)$. At the same moment, the pair $(a+t, t)$ becomes excellent instead.  This process halts when the point $Q_{\nu}(t)$ eventually disappears, i.e. when $\nu$ passes through the ratio of the coordinates of the point $T=C_{\nu}(t)$. Hence, the point $T$ afterwards is regarded as $F_{\nu}(t)$. Thus, all the old excellent pairs of the form $(a, t)$ with $a>t$ disappear; on the other hand, the same number of excellent pairs with the first element being $t$ just appear.  Similarly, if some pair $(t, b)$ with $t<b$ is initially $\nu$-excellent, then at some moment it stops being excellent when $P_{\nu}(t)$ passes through $C_{\nu}(b)$; at the same moment, the pair $(t, b-t)$ becomes excellent. This process eventually stops when $b-t<t$. At this moment, again the second element of the pair becomes fixed, and the first one starts to increase.  These ideas can be made precise enough to show that the number of excellent pairs remains unchanged, as required.  We should warn the reader that the rigorous elaboration of Part II is technically quite involved, mostly by the reason that the set of moments when the collection of excellent pairs changes is infinite. Especially much care should be applied to the limit points of this set, which are exactly the points when the line $\ell_{\nu}$ passes through some point of the form $C_{\nu}(b)$.  The same ideas may be explained in an algebraic language instead of a geometrical one; the same technicalities remain in this way as well.


Let $\mathbb{Q}_{>0}$ be the set of positive rational numbers. Let $f: \mathbb{Q}_{>0} \rightarrow \mathbb{R}$ be a function satisfying the conditions  $$ \begin{aligned} & f(x) f(y) \geqslant f(x y) \\ & f(x+y) \geqslant f(x)+f(y) \end{aligned} $$  for all $x, y \in \mathbb{Q}_{>0}$. Given that $f(a)=a$ for some rational $a>1$, prove that $f(x)=x$ for all $x \in \mathbb{Q}_{>0}$.  (Bulgaria)

Solution: Denote by $\mathbb{Z}_{>0}$ the set of positive integers.  Plugging $x=1, y=a$ into (1) we get $f(1) \geqslant 1$. Next, by an easy induction on $n$ we get from (2) that  $$ f(n x) \geqslant n f(x) \text { for all } n \in \mathbb{Z}_{>0} \text { and } x \in \mathbb{Q}_{>0} $$  In particular, we have  $$ f(n) \geqslant n f(1) \geqslant n \quad \text { for all } n \in \mathbb{Z}_{>0} $$  From (1) again we have $f(m / n) f(n) \geqslant f(m)$, so $f(q)>0$ for all $q \in \mathbb{Q}_{>0}$.  Now, (2) implies that $f$ is strictly increasing; this fact together with (4) yields  $$ f(x) \geqslant f(\lfloor x\rfloor) \geqslant\lfloor x\rfloor>x-1 \quad \text { for all } x \geqslant 1 $$  By an easy induction we get from (1) that $f(x)^{n} \geqslant f\left(x^{n}\right)$, so  $$ f(x)^{n} \geqslant f\left(x^{n}\right)>x^{n}-1 \quad \Longrightarrow \quad f(x) \geqslant \sqrt[n]{x^{n}-1} \text { for all } x>1 \text { and } n \in \mathbb{Z}_{>0} $$  This yields  $$ f(x) \geqslant x \text { for every } x>1 \text {. } $$  (Indeed, if $x>y>1$ then $x^{n}-y^{n}=(x-y)\left(x^{n-1}+x^{n-2} y+\cdots+y^{n}\right)>n(x-y)$, so for a large $n$ we have $x^{n}-1>y^{n}$ and thus $f(x)>y$.)  Now, (1) and (5) give $a^{n}=f(a)^{n} \geqslant f\left(a^{n}\right) \geqslant a^{n}$, so $f\left(a^{n}\right)=a^{n}$. Now, for $x>1$ let us choose $n \in \mathbb{Z}_{>0}$ such that $a^{n}-x>1$. Then by (2) and (5) we get  $$ a^{n}=f\left(a^{n}\right) \geqslant f(x)+f\left(a^{n}-x\right) \geqslant x+\left(a^{n}-x\right)=a^{n} $$  and therefore $f(x)=x$ for $x>1$. Finally, for every $x \in \mathbb{Q}_{>0}$ and every $n \in \mathbb{Z}_{>0}$, from (1) and (3) we get  $$ n f(x)=f(n) f(x) \geqslant f(n x) \geqslant n f(x) $$  which gives $f(n x)=n f(x)$. Therefore $f(m / n)=f(m) / n=m / n$ for all $m, n \in \mathbb{Z}_{>0}$.  Comment. The condition $f(a)=a>1$ is essential. Indeed, for $b \geqslant 1$ the function $f(x)=b x^{2}$ satisfies (1) and (2) for all $x, y \in \mathbb{Q}_{>0}$, and it has a unique fixed point $1 / b \leqslant 1$.


Let $\mathbb{Z}_{\geqslant 0}$ be the set of all nonnegative integers. Find all the functions $f: \mathbb{Z}_{\geqslant 0} \rightarrow \mathbb{Z}_{\geqslant 0}$ satisfying the relation  $$ f(f(f(n)))=f(n+1)+1 $$  for all $n \in \mathbb{Z}_{\geqslant 0}$.  (Serbia)  Answer. There are two such functions: $f(n)=n+1$ for all $n \in \mathbb{Z}_{\geqslant 0}$, and  $$ f(n)=\left\{\begin{array}{ll} n+1, & n \equiv 0(\bmod 4) \text { or } n \equiv 2(\bmod 4), \\ n+5, & n \equiv 1(\bmod 4), \\ n-3, & n \equiv 3(\bmod 4) \end{array} \quad \text { for all } n \in \mathbb{Z}_{\geqslant 0}\right. $$  Throughout all the solutions, we write $h^{k}(x)$ to abbreviate the $k$ th iteration of function $h$, so $h^{0}$ is the identity function, and $h^{k}(x)=\underbrace{h(\ldots h}_{k \text { times }}(x) \ldots))$ for $k \geqslant 1$.

Solution: To start, we get from (*) that  $$ f^{4}(n)=f\left(f^{3}(n)\right)=f(f(n+1)+1) \quad \text { and } \quad f^{4}(n+1)=f^{3}(f(n+1))=f(f(n+1)+1)+1 $$  thus  $$ f^{4}(n)+1=f^{4}(n+1) . $$  I. Let us denote by $R_{i}$ the range of $f^{i}$; note that $R_{0}=\mathbb{Z}_{\geqslant 0}$ since $f^{0}$ is the identity function. Obviously, $R_{0} \supseteq R_{1} \supseteq \ldots$ Next, from (2) we get that if $a \in R_{4}$ then also $a+1 \in R_{4}$. This implies that $\mathbb{Z}_{\geqslant 0} \backslash R_{4}$ - and hence $\mathbb{Z}_{\geqslant 0} \backslash R_{1}$ - is finite. In particular, $R_{1}$ is unbounded.  Assume that $f(m)=f(n)$ for some distinct $m$ and $n$. Then from $(*)$ we obtain $f(m+1)=$ $f(n+1)$; by an easy induction we then get that $f(m+c)=f(n+c)$ for every $c \geqslant 0$. So the function $f(k)$ is periodic with period $|m-n|$ for $k \geqslant m$, and thus $R_{1}$ should be bounded, which is false. So, $f$ is injective.  II. Denote now $S_{i}=R_{i-1} \backslash R_{i}$; all these sets are finite for $i \leqslant 4$. On the other hand, by the injectivity we have $n \in S_{i} \Longleftrightarrow f(n) \in S_{i+1}$. By the injectivity again, $f$ implements a bijection between $S_{i}$ and $S_{i+1}$, thus $\left|S_{1}\right|=\left|S_{2}\right|=\ldots$; denote this common cardinality by $k$. If $0 \in R_{3}$ then $0=f(f(f(n)))$ for some $n$, thus from (*) we get $f(n+1)=-1$ which is impossible. Therefore $0 \in R_{0} \backslash R_{3}=S_{1} \cup S_{2} \cup S_{3}$, thus $k \geqslant 1$.  Next, let us describe the elements $b$ of $R_{0} \backslash R_{3}=S_{1} \cup S_{2} \cup S_{3}$. We claim that each such element satisfies at least one of three conditions $(i) b=0,(i i) b=f(0)+1$, and (iii) $b-1 \in S_{1}$. Otherwise $b-1 \in \mathbb{Z}_{\geqslant 0}$, and there exists some $n>0$ such that $f(n)=b-1$; but then $f^{3}(n-1)=f(n)+1=b$, so $b \in R_{3}$.  This yields  $$ 3 k=\left|S_{1} \cup S_{2} \cup S_{3}\right| \leqslant 1+1+\left|S_{1}\right|=k+2, $$  or $k \leqslant 1$. Therefore $k=1$, and the inequality above comes to equality. So we have $S_{1}=\{a\}$, $S_{2}=\{f(a)\}$, and $S_{3}=\left\{f^{2}(a)\right\}$ for some $a \in \mathbb{Z}_{\geqslant 0}$, and each one of the three options (i), (ii), and (iii) should be realized exactly once, which means that  $$ \left\{a, f(a), f^{2}(a)\right\}=\{0, a+1, f(0)+1\} . $$  III. From (3), we get $a+1 \in\left\{f(a), f^{2}(a)\right\}$ (the case $a+1=a$ is impossible). If $a+1=f^{2}(a)$ then we have $f(a+1)=f^{3}(a)=f(a+1)+1$ which is absurd. Therefore  $$ f(a)=a+1 $$  Next, again from (3) we have $0 \in\left\{a, f^{2}(a)\right\}$. Let us consider these two cases separately. Case 1. Assume that $a=0$, then $f(0)=f(a)=a+1=1$. Also from (3) we get $f(1)=f^{2}(a)=$ $f(0)+1=2$. Now, let us show that $f(n)=n+1$ by induction on $n$; the base cases $n \leqslant 1$ are established. Next, if $n \geqslant 2$ then the induction hypothesis implies  $$ n+1=f(n-1)+1=f^{3}(n-2)=f^{2}(n-1)=f(n), $$  establishing the step. In this case we have obtained the first of two answers; checking that is satisfies (*) is straightforward.  Case 2. Assume now that $f^{2}(a)=0$; then by (3) we get $a=f(0)+1$. By (4) we get $f(a+1)=$ $f^{2}(a)=0$, then $f(0)=f^{3}(a)=f(a+1)+1=1$, hence $a=f(0)+1=2$ and $f(2)=3$ by (4). To summarize,  $$ f(0)=1, \quad f(2)=3, \quad f(3)=0 . $$  Now let us prove by induction on $m$ that (1) holds for all $n=4 k, 4 k+2,4 k+3$ with $k \leqslant m$ and for all $n=4 k+1$ with $k<m$. The base case $m=0$ is established above. For the step, assume that $m \geqslant 1$. From (*) we get $f^{3}(4 m-3)=f(4 m-2)+1=4 m$. Next, by (2) we have  $$ f(4 m)=f^{4}(4 m-3)=f^{4}(4 m-4)+1=f^{3}(4 m-3)+1=4 m+1 . $$  Then by the induction hypothesis together with (*) we successively obtain  $$ \begin{aligned} & f(4 m-3)=f^{3}(4 m-1)=f(4 m)+1=4 m+2, \\ & f(4 m+2)=f^{3}(4 m-4)=f(4 m-3)+1=4 m+3, \\ & f(4 m+3)=f^{3}(4 m-3)=f(4 m-2)+1=4 m, \end{aligned} $$  thus finishing the induction step.  Finally, it is straightforward to check that the constructed function works:  $$ \begin{aligned} & f^{3}(4 k)=4 k+7=f(4 k+1)+1, \quad f^{3}(4 k+1)=4 k+4=f(4 k+2)+1, \\ & f^{3}(4 k+2)=4 k+1=f(4 k+3)+1, \quad f^{3}(4 k+3)=4 k+6=f(4 k+4)+1 . \end{aligned} $$


Solution: I. For convenience, let us introduce the function $g(n)=f(n)+1$. Substituting $f(n)$ instead of $n$ into (*) we obtain  $$ f^{4}(n)=f(f(n)+1)+1, \quad \text { or } \quad f^{4}(n)=g^{2}(n) . $$  Applying $f$ to both parts of (*) and using (5) we get  $$ f^{4}(n)+1=f(f(n+1)+1)+1=f^{4}(n+1) . $$  Thus, if $g^{2}(0)=f^{4}(0)=c$ then an easy induction on $n$ shows that  $$ g^{2}(n)=f^{4}(n)=n+c, \quad n \in \mathbb{Z}_{\geqslant 0} $$  This relation implies that both $f$ and $g$ are injective: if, say, $f(m)=f(n)$ then $m+c=$ $f^{4}(m)=f^{4}(n)=n+c$. Next, since $g(n) \geqslant 1$ for every $n$, we have $c=g^{2}(0) \geqslant 1$. Thus from (7) again we obtain $f(n) \neq n$ and $g(n) \neq n$ for all $n \in \mathbb{Z}_{\geqslant 0}$.  II. Next, application of $f$ and $g$ to (7) yields  $$ f(n+c)=f^{5}(n)=f^{4}(f(n))=f(n)+c \quad \text { and } \quad g(n+c)=g^{3}(n)=g(n)+c \text {. } $$  In particular, this means that if $m \equiv n(\bmod c)$ then $f(m) \equiv f(n)(\bmod c)$. Conversely, if $f(m) \equiv f(n)(\bmod c)$ then we get $m+c=f^{4}(m) \equiv f^{4}(n)=n+c(\bmod c)$. Thus,  $$ m \equiv n \quad(\bmod c) \Longleftrightarrow f(m) \equiv f(n) \quad(\bmod c) \Longleftrightarrow g(m) \equiv g(n) \quad(\bmod c) $$  Now, let us introduce the function $\delta(n)=f(n)-n=g(n)-n-1$. Set  $$ S=\sum_{n=0}^{c-1} \delta(n) $$  Using (8), we get that for every complete residue system $n_{1}, \ldots, n_{c}$ modulo $c$ we also have  $$ S=\sum_{i=1}^{c} \delta\left(n_{i}\right) $$  By (9), we get that $\left\{f^{k}(n): n=0, \ldots, c-1\right\}$ and $\left\{g^{k}(n): n=0, \ldots, c-1\right\}$ are complete residue systems modulo $c$ for all $k$. Thus we have  $$ c^{2}=\sum_{n=0}^{c-1}\left(f^{4}(n)-n\right)=\sum_{k=0}^{3} \sum_{n=0}^{c-1}\left(f^{k+1}(n)-f^{k}(n)\right)=\sum_{k=0}^{3} \sum_{n=0}^{c-1} \delta\left(f^{k}(n)\right)=4 S $$  and similarly  $$ c^{2}=\sum_{n=0}^{c-1}\left(g^{2}(n)-n\right)=\sum_{k=0}^{1} \sum_{n=0}^{c-1}\left(g^{k+1}(n)-g^{k}(n)\right)=\sum_{k=0}^{1} \sum_{n=0}^{c-1}\left(\delta\left(g^{k}(n)\right)+1\right)=2 S+2 c . $$  Therefore $c^{2}=4 S=2 \cdot 2 S=2\left(c^{2}-2 c\right)$, or $c^{2}=4 c$. Since $c \neq 0$, we get $c=4$. Thus, in view of (8) it is sufficient to determine the values of $f$ on the numbers $0,1,2,3$.  III. Let $d=g(0) \geqslant 1$. Then $g(d)=g^{2}(0)=0+c=4$. Now, if $d \geqslant 4$, then we would have $g(d-4)=g(d)-4=0$ which is impossible. Thus $d \in\{1,2,3\}$. If $d=1$ then we have $f(0)=g(0)-1=0$ which is impossible since $f(n) \neq n$ for all $n$. If $d=3$ then $g(3)=g^{2}(0)=4$ and hence $f(3)=3$ which is also impossible. Thus $g(0)=2$ and hence $g(2)=g^{2}(0)=4$.  Next, if $g(1)=1+4 k$ for some integer $k$, then $5=g^{2}(1)=g(1+4 k)=g(1)+4 k=1+8 k$ which is impossible. Thus, since $\{g(n): n=0,1,2,3\}$ is a complete residue system modulo 4 , we get $g(1)=3+4 k$ and hence $g(3)=g^{2}(1)-4 k=5-4 k$, leading to $k=0$ or $k=1$. So, we obtain iether  $$ f(0)=1, f(1)=2, f(2)=3, f(3)=4, \quad \text { or } \quad f(0)=1, f(1)=6, f(2)=3, f(3)=0 $$  thus arriving to the two functions listed in the answer.  Finally, one can check that these two function work as in Solution 1. One may simplify the checking by noticing that (8) allows us to reduce it to $n=0,1,2,3$.


Let $m \neq 0$ be an integer. Find all polynomials $P(x)$ with real coefficients such that  $$ \left(x^{3}-m x^{2}+1\right) P(x+1)+\left(x^{3}+m x^{2}+1\right) P(x-1)=2\left(x^{3}-m x+1\right) P(x) $$  for all real numbers $x$.  (Serbia)  Answer. $P(x)=t x$ for any real number $t$.

Solution: Let $P(x)=a_{n} x^{n}+\cdots+a_{0} x^{0}$ with $a_{n} \neq 0$. Comparing the coefficients of $x^{n+1}$ on both sides gives $a_{n}(n-2 m)(n-1)=0$, so $n=1$ or $n=2 m$.  If $n=1$, one easily verifies that $P(x)=x$ is a solution, while $P(x)=1$ is not. Since the given condition is linear in $P$, this means that the linear solutions are precisely $P(x)=t x$ for $t \in \mathbb{R}$.  Now assume that $n=2 m$. The polynomial $x P(x+1)-(x+1) P(x)=(n-1) a_{n} x^{n}+\cdots$ has degree $n$, and therefore it has at least one (possibly complex) root $r$. If $r \notin\{0,-1\}$, define $k=P(r) / r=P(r+1) /(r+1)$. If $r=0$, let $k=P(1)$. If $r=-1$, let $k=-P(-1)$. We now consider the polynomial $S(x)=P(x)-k x$. It also satisfies (1) because $P(x)$ and $k x$ satisfy it. Additionally, it has the useful property that $r$ and $r+1$ are roots.  Let $A(x)=x^{3}-m x^{2}+1$ and $B(x)=x^{3}+m x^{2}+1$. Plugging in $x=s$ into (1) implies that:  If $s-1$ and $s$ are roots of $S$ and $s$ is not a root of $A$, then $s+1$ is a root of $S$.  If $s$ and $s+1$ are roots of $S$ and $s$ is not a root of $B$, then $s-1$ is a root of $S$.  Let $a \geqslant 0$ and $b \geqslant 1$ be such that $r-a, r-a+1, \ldots, r, r+1, \ldots, r+b-1, r+b$ are roots of $S$, while $r-a-1$ and $r+b+1$ are not. The two statements above imply that $r-a$ is a root of $B$ and $r+b$ is a root of $A$.  Since $r-a$ is a root of $B(x)$ and of $A(x+a+b)$, it is also a root of their greatest common divisor $C(x)$ as integer polynomials. If $C(x)$ was a non-trivial divisor of $B(x)$, then $B$ would have a rational root $\alpha$. Since the first and last coefficients of $B$ are $1, \alpha$ can only be 1 or -1 ; but $B(-1)=m>0$ and $B(1)=m+2>0$ since $n=2 m$.  Therefore $B(x)=A(x+a+b)$. Writing $c=a+b \geqslant 1$ we compute  $$ 0=A(x+c)-B(x)=(3 c-2 m) x^{2}+c(3 c-2 m) x+c^{2}(c-m) . $$  Then we must have $3 c-2 m=c-m=0$, which gives $m=0$, a contradiction. We conclude that $f(x)=t x$ is the only solution.


Solution: Multiplying (1) by $x$, we rewrite it as  $$ x\left(x^{3}-m x^{2}+1\right) P(x+1)+x\left(x^{3}+m x^{2}+1\right) P(x-1)=[(x+1)+(x-1)]\left(x^{3}-m x+1\right) P(x) . $$  After regrouping, it becomes  $$ \left(x^{3}-m x^{2}+1\right) Q(x)=\left(x^{3}+m x^{2}+1\right) Q(x-1) \text {, } $$  where $Q(x)=x P(x+1)-(x+1) P(x)$. If $\operatorname{deg} P \geqslant 2$ then $\operatorname{deg} Q=\operatorname{deg} P$, so $Q(x)$ has a finite multiset of complex roots, which we denote $R_{Q}$. Each root is taken with its multiplicity. Then the multiset of complex roots of $Q(x-1)$ is $R_{Q}+1=\left\{z+1: z \in R_{Q}\right\}$.  Let $\left\{x_{1}, x_{2}, x_{3}\right\}$ and $\left\{y_{1}, y_{2}, y_{3}\right\}$ be the multisets of roots of the polynomials $A(x)=x^{3}-m x^{2}+1$ and $B(x)=x^{3}+m x^{2}+1$, respectively. From (2) we get the equality of multisets  $$ \left\{x_{1}, x_{2}, x_{3}\right\} \cup R_{Q}=\left\{y_{1}, y_{2}, y_{3}\right\} \cup\left(R_{Q}+1\right) . $$  For every $r \in R_{Q}$, since $r+1$ is in the set of the right hand side, we must have $r+1 \in R_{Q}$ or $r+1=x_{i}$ for some $i$. Similarly, since $r$ is in the set of the left hand side, either $r-1 \in R_{Q}$ or $r=y_{i}$ for some $i$. This implies that, possibly after relabelling $y_{1}, y_{2}, y_{3}$, all the roots of (2) may be partitioned into three chains of the form $\left\{y_{i}, y_{i}+1, \ldots, y_{i}+k_{i}=x_{i}\right\}$ for $i=1,2,3$ and some integers $k_{1}, k_{2}, k_{3} \geqslant 0$.  Now we analyze the roots of the polynomial $A_{a}(x)=x^{3}+a x^{2}+1$. Using calculus or elementary methods, we find that the local extrema of $A_{a}(x)$ occur at $x=0$ and $x=-2 a / 3$; their values are $A_{a}(0)=1>0$ and $A_{a}(-2 a / 3)=1+4 a^{3} / 27$, which is positive for integers $a \geqslant-1$ and negative for integers $a \leqslant-2$. So when $a \in \mathbb{Z}, A_{a}$ has three real roots if $a \leqslant-2$ and one if $a \geqslant-1$.  Now, since $y_{i}-x_{i} \in \mathbb{Z}$ for $i=1,2,3$, the cubics $A_{m}$ and $A_{-m}$ must have the same number of real roots. The previous analysis then implies that $m=1$ or $m=-1$. Therefore the real root $\alpha$ of $A_{1}(x)=x^{3}+x^{2}+1$ and the real root $\beta$ of $A_{-1}(x)=x^{3}-x^{2}+1$ must differ by an integer. But this is impossible, because $A_{1}\left(-\frac{3}{2}\right)=-\frac{1}{8}$ and $A_{1}(-1)=1$ so $-1.5<\alpha<-1$, while $A_{-1}(-1)=-1$ and $A_{-1}\left(-\frac{1}{2}\right)=\frac{5}{8}$, so $-1<\beta<-0.5$.  It follows that $\operatorname{deg} P \leqslant 1$. Then, as shown in Solution 1, we conclude that the solutions are $P(x)=t x$ for all real numbers $t$.


Let $n$ be a positive integer. Find the smallest integer $k$ with the following property: Given any real numbers $a_{1}, \ldots, a_{d}$ such that $a_{1}+a_{2}+\cdots+a_{d}=n$ and $0 \leqslant a_{i} \leqslant 1$ for $i=1,2, \ldots, d$, it is possible to partition these numbers into $k$ groups (some of which may be empty) such that the sum of the numbers in each group is at most 1 .  (Poland)  Answer. $k=2 n-1$.

Solution: If $d=2 n-1$ and $a_{1}=\cdots=a_{2 n-1}=n /(2 n-1)$, then each group in such a partition can contain at most one number, since $2 n /(2 n-1)>1$. Therefore $k \geqslant 2 n-1$. It remains to show that a suitable partition into $2 n-1$ groups always exists.  We proceed by induction on $d$. For $d \leqslant 2 n-1$ the result is trivial. If $d \geqslant 2 n$, then since  $$ \left(a_{1}+a_{2}\right)+\ldots+\left(a_{2 n-1}+a_{2 n}\right) \leqslant n $$  we may find two numbers $a_{i}, a_{i+1}$ such that $a_{i}+a_{i+1} \leqslant 1$. We "merge" these two numbers into one new number $a_{i}+a_{i+1}$. By the induction hypothesis, a suitable partition exists for the $d-1$ numbers $a_{1}, \ldots, a_{i-1}, a_{i}+a_{i+1}, a_{i+2}, \ldots, a_{d}$. This induces a suitable partition for $a_{1}, \ldots, a_{d}$.


Solution: We will show that it is even possible to split the sequence $a_{1}, \ldots, a_{d}$ into $2 n-1$ contiguous groups so that the sum of the numbers in each groups does not exceed 1. Consider a segment $S$ of length $n$, and partition it into segments $S_{1}, \ldots, S_{d}$ of lengths $a_{1}, \ldots, a_{d}$, respectively, as shown below. Consider a second partition of $S$ into $n$ equal parts by $n-1$ "empty dots".  | $a_{1}$ | $a_{2}$ | $a_{3}$ | $a_{4}$ | $a_{5}$ | $a_{6}$ | $a_{7}$ | $a_{8}, a_{9}, a_{10}$ | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | |  |  |  |  |  |  |  |  |  Assume that the $n-1$ empty dots are in segments $S_{i_{1}}, \ldots, S_{i_{n-1}}$. (If a dot is on the boundary of two segments, we choose the right segment). These $n-1$ segments are distinct because they have length at most 1. Consider the partition:  $$ \left\{a_{1}, \ldots, a_{i_{1}-1}\right\},\left\{a_{i_{1}}\right\},\left\{a_{i_{1}+1}, \ldots, a_{i_{2}-1}\right\},\left\{a_{i_{2}}\right\}, \ldots\left\{a_{i_{n-1}}\right\},\left\{a_{i_{n-1}+1}, \ldots, a_{d}\right\} $$  In the example above, this partition is $\left\{a_{1}, a_{2}\right\},\left\{a_{3}\right\},\left\{a_{4}, a_{5}\right\},\left\{a_{6}\right\}, \varnothing,\left\{a_{7}\right\},\left\{a_{8}, a_{9}, a_{10}\right\}$. We claim that in this partition, the sum of the numbers in this group is at most 1 .  For the sets $\left\{a_{i_{t}}\right\}$ this is obvious since $a_{i_{t}} \leqslant 1$. For the sets $\left\{a_{i_{t}}+1, \ldots, a_{i_{t+1}-1}\right\}$ this follows from the fact that the corresponding segments lie between two neighboring empty dots, or between an endpoint of $S$ and its nearest empty dot. Therefore the sum of their lengths cannot exceed 1.


Solution: First put all numbers greater than $\frac{1}{2}$ in their own groups. Then, form the remaining groups as follows: For each group, add new $a_{i} \mathrm{~S}$ one at a time until their sum exceeds $\frac{1}{2}$. Since the last summand is at most $\frac{1}{2}$, this group has sum at most 1 . Continue this procedure until we have used all the $a_{i}$ s. Notice that the last group may have sum less than $\frac{1}{2}$. If the sum of the numbers in the last two groups is less than or equal to 1, we merge them into one group. In the end we are left with $m$ groups. If $m=1$ we are done. Otherwise the first $m-2$ have sums greater than $\frac{1}{2}$ and the last two have total sum greater than 1 . Therefore $n>(m-2) / 2+1$ so $m \leqslant 2 n-1$ as desired.  Comment 1. The original proposal asked for the minimal value of $k$ when $n=2$.  Comment 2. More generally, one may ask the same question for real numbers between 0 and 1 whose sum is a real number $r$. In this case the smallest value of $k$ is $k=\lceil 2 r\rceil-1$, as Solution 3 shows.  Solutions 1 and 2 lead to the slightly weaker bound $k \leqslant 2\lceil r\rceil-1$. This is actually the optimal bound for partitions into consecutive groups, which are the ones contemplated in these two solutions. To see this, assume that $r$ is not an integer and let $c=(r+1-\lceil r\rceil) /(1+\lceil r\rceil)$. One easily checks that $0<c<\frac{1}{2}$ and $\lceil r\rceil(2 c)+(\lceil r\rceil-1)(1-c)=r$, so the sequence  $$ 2 c, 1-c, 2 c, 1-c, \ldots, 1-c, 2 c $$  of $2\lceil r\rceil-1$ numbers satisfies the given conditions. For this sequence, the only suitable partition into consecutive groups is the trivial partition, which requires $2\lceil r\rceil-1$ groups.


In the plane, 2013 red points and 2014 blue points are marked so that no three of the marked points are collinear. One needs to draw $k$ lines not passing through the marked points and dividing the plane into several regions. The goal is to do it in such a way that no region contains points of both colors.  Find the minimal value of $k$ such that the goal is attainable for every possible configuration of 4027 points.  (Australia)  Answer. $k=2013$.

Solution: Firstly, let us present an example showing that $k \geqslant 2013$. Mark 2013 red and 2013 blue points on some circle alternately, and mark one more blue point somewhere in the plane. The circle is thus split into 4026 arcs, each arc having endpoints of different colors. Thus, if the goal is reached, then each arc should intersect some of the drawn lines. Since any line contains at most two points of the circle, one needs at least 4026/2 $=2013$ lines.  It remains to prove that one can reach the goal using 2013 lines. First of all, let us mention that for every two points $A$ and $B$ having the same color, one can draw two lines separating these points from all other ones. Namely, it suffices to take two lines parallel to $A B$ and lying on different sides of $A B$ sufficiently close to it: the only two points between these lines will be $A$ and $B$.  Now, let $P$ be the convex hull of all marked points. Two cases are possible.  Case 1. Assume that $P$ has a red vertex $A$. Then one may draw a line separating $A$ from all the other points, pair up the other 2012 red points into 1006 pairs, and separate each pair from the other points by two lines. Thus, 2013 lines will be used.  Case 2. Assume now that all the vertices of $P$ are blue. Consider any two consecutive vertices of $P$, say $A$ and $B$. One may separate these two points from the others by a line parallel to $A B$. Then, as in the previous case, one pairs up all the other 2012 blue points into 1006 pairs, and separates each pair from the other points by two lines. Again, 2013 lines will be used.  Comment 1. Instead of considering the convex hull, one may simply take a line containing two marked points $A$ and $B$ such that all the other marked points are on one side of this line. If one of $A$ and $B$ is red, then one may act as in Case 1; otherwise both are blue, and one may act as in Case 2.


Solution: Let us present a different proof of the fact that $k=2013$ suffices. In fact, we will prove a more general statement:  If $n$ points in the plane, no three of which are collinear, are colored in red and blue arbitrarily, then it suffices to draw $\lfloor n / 2\rfloor$ lines to reach the goal.  We proceed by induction on $n$. If $n \leqslant 2$ then the statement is obvious. Now assume that $n \geqslant 3$, and consider a line $\ell$ containing two marked points $A$ and $B$ such that all the other marked points are on one side of $\ell$; for instance, any line containing a side of the convex hull works.  Remove for a moment the points $A$ and $B$. By the induction hypothesis, for the remaining configuration it suffices to draw $\lfloor n / 2\rfloor-1$ lines to reach the goal. Now return the points $A$ and $B$ back. Three cases are possible.  Case 1. If $A$ and $B$ have the same color, then one may draw a line parallel to $\ell$ and separating $A$ and $B$ from the other points. Obviously, the obtained configuration of $\lfloor n / 2\rfloor$ lines works.  Case 2. If $A$ and $B$ have different colors, but they are separated by some drawn line, then again the same line parallel to $\ell$ works.  Case 3. Finally, assume that $A$ and $B$ have different colors and lie in one of the regions defined by the drawn lines. By the induction assumption, this region contains no other points of one of the colors - without loss of generality, the only blue point it contains is $A$. Then it suffices to draw a line separating $A$ from all other points.  Thus the step of the induction is proved.  Comment 2. One may ask a more general question, replacing the numbers 2013 and 2014 by any positive integers $m$ and $n$, say with $m \leqslant n$. Denote the answer for this problem by $f(m, n)$.  One may show along the lines of Solution 1 that $m \leqslant f(m, n) \leqslant m+1$; moreover, if $m$ is even then $f(m, n)=m$. On the other hand, for every odd $m$ there exists an $N$ such that $f(m, n)=m$ for all $m \leqslant n \leqslant N$, and $f(m, n)=m+1$ for all $n>N$.


Let $r$ be a positive integer, and let $a_{0}, a_{1}, \ldots$ be an infinite sequence of real numbers. Assume that for all nonnegative integers $m$ and $s$ there exists a positive integer $n \in[m+1, m+r]$ such that  $$ a_{m}+a_{m+1}+\cdots+a_{m+s}=a_{n}+a_{n+1}+\cdots+a_{n+s} $$  Prove that the sequence is periodic, i. e. there exists some $p \geqslant 1$ such that $a_{n+p}=a_{n}$ for all $n \geqslant 0$.  (India)

Solution: For every indices $m \leqslant n$ we will denote $S(m, n)=a_{m}+a_{m+1}+\cdots+a_{n-1}$; thus $S(n, n)=0$. Let us start with the following lemma.  Lemma. Let $b_{0}, b_{1}, \ldots$ be an infinite sequence. Assume that for every nonnegative integer $m$ there exists a nonnegative integer $n \in[m+1, m+r]$ such that $b_{m}=b_{n}$. Then for every indices $k \leqslant \ell$ there exists an index $t \in[\ell, \ell+r-1]$ such that $b_{t}=b_{k}$. Moreover, there are at most $r$ distinct numbers among the terms of $\left(b_{i}\right)$.  Proof. To prove the first claim, let us notice that there exists an infinite sequence of indices $k_{1}=k, k_{2}, k_{3}, \ldots$ such that $b_{k_{1}}=b_{k_{2}}=\cdots=b_{k}$ and $k_{i}<k_{i+1} \leqslant k_{i}+r$ for all $i \geqslant 1$. This sequence is unbounded from above, thus it hits each segment of the form $[\ell, \ell+r-1]$ with $\ell \geqslant k$, as required.  To prove the second claim, assume, to the contrary, that there exist $r+1$ distinct numbers $b_{i_{1}}, \ldots, b_{i_{r+1}}$. Let us apply the first claim to $k=i_{1}, \ldots, i_{r+1}$ and $\ell=\max \left\{i_{1}, \ldots, i_{r+1}\right\}$; we obtain that for every $j \in\{1, \ldots, r+1\}$ there exists $t_{j} \in[s, s+r-1]$ such that $b_{t_{j}}=b_{i_{j}}$. Thus the segment $[s, s+r-1]$ should contain $r+1$ distinct integers, which is absurd.  Setting $s=0$ in the problem condition, we see that the sequence $\left(a_{i}\right)$ satisfies the condition of the lemma, thus it attains at most $r$ distinct values. Denote by $A_{i}$ the ordered $r$-tuple $\left(a_{i}, \ldots, a_{i+r-1}\right)$; then among $A_{i}$ 's there are at most $r^{r}$ distinct tuples, so for every $k \geqslant 0$ two of the tuples $A_{k}, A_{k+1}, \ldots, A_{k+r^{r}}$ are identical. This means that there exists a positive integer $p \leqslant r^{r}$ such that the equality $A_{d}=A_{d+p}$ holds infinitely many times. Let $D$ be the set of indices $d$ satisfying this relation.  Now we claim that $D$ coincides with the set of all nonnegative integers. Since $D$ is unbounded, it suffices to show that $d \in D$ whenever $d+1 \in D$. For that, denote $b_{k}=S(k, p+k)$. The sequence $b_{0}, b_{1}, \ldots$ satisfies the lemma conditions, so there exists an index $t \in[d+1, d+r]$ such that $S(t, t+p)=S(d, d+p)$. This last relation rewrites as $S(d, t)=S(d+p, t+p)$. Since $A_{d+1}=A_{d+p+1}$, we have $S(d+1, t)=S(d+p+1, t+p)$, therefore we obtain  $$ a_{d}=S(d, t)-S(d+1, t)=S(d+p, t+p)-S(d+p+1, t+p)=a_{d+p} $$  and thus $A_{d}=A_{d+p}$, as required.  Finally, we get $A_{d}=A_{d+p}$ for all $d$, so in particular $a_{d}=a_{d+p}$ for all $d$, QED.  Comment 1. In the present proof, the upper bound for the minimal period length is $r^{r}$. This bound is not sharp; for instance, one may improve it to $(r-1)^{r}$ for $r \geqslant 3$..  On the other hand, this minimal length may happen to be greater than $r$. For instance, it is easy to check that the sequence with period $(3,-3,3,-3,3,-1,-1,-1)$ satisfies the problem condition for $r=7$.  Comment 2. The conclusion remains true even if the problem condition only holds for every $s \geqslant N$ for some positive integer $N$. To show that, one can act as follows. Firstly, the sums of the form $S(i, i+N)$ attain at most $r$ values, as well as the sums of the form $S(i, i+N+1)$. Thus the terms $a_{i}=S(i, i+N+1)-$ $S(i+1, i+N+1)$ attain at most $r^{2}$ distinct values. Then, among the tuples $A_{k}, A_{k+N}, \ldots, A_{k+r^{2 r} N}$ two are identical, so for some $p \leqslant r^{2 r}$ the set $D=\left\{d: A_{d}=A_{d+N p}\right\}$ is infinite. The further arguments apply almost literally, with $p$ being replaced by $N p$.  After having proved that such a sequence is also necessarily periodic, one may reduce the bound for the minimal period length to $r^{r}$ - essentially by verifying that the sequence satisfies the original version of the condition.