exam: EGMO

problem:
Determine all integers $n \geq 2$ for which there exist integers $x_{1}, x_{2}, \ldots, x_{n-1}$ satisfying the condition that if $0<i<n, 0<j<n, i \neq j$ and $n$ divides $2 i+j$, then $x_{i}<x_{j}$.

Proposed by Merlijn Staps, NLD
The answer is that $n=2^{k}$ with $k \geq 1$ or $n=3 \cdot 2^{k}$ where $k \geq 0$.

solution:
Suppose that $n$ has one of these forms. For an integer $i$, let $x_{i}$ be the largest integer such that $2^{x_{i}}$ divides $i$. Now assume that $0<i<n, 0<j<n, i \neq j, n$ divides $2 i+j$ and $x_{i} \geq x_{j}$. Then the highest power of 2 dividing $2 i+j$ is $2^{x_{j}}$ and therefore $k \leq x_{j}$ and $2^{k} \leq j$. Since $0<j<n$, this is possible only if $n=3 \cdot 2^{k}$ and either $j=2^{k}$ or $j=2^{k+1}$. In the first case, $i \neq j$ and $x_{i} \geq x_{j}$ imply $i=2^{k+1}$ leading to the contradiction $3 \cdot 2^{k}=n \mid 2 i+j=5 \cdot 2^{k}$. The second case is not possible as $i \neq j$ and $x_{i} \geq x_{j}$ now imply $i \geq 2^{k+2}>n$.

Now suppose that $n$ does not have one of these forms and $x_{1}, x_{2}, \ldots, x_{n-1}$ satisfying the given condition exist. For any positive integer $m$, let $a_{m}$ be the remainder of the division of $(-2)^{m}$ by $n$. Then none of $a_{m}$ is 0 as $n$ is not a power of 2. Also $a_{m} \neq a_{m+1}$ for any $m \geq 1$ as $a_{m}=a_{m+1}$ would lead to $n$ dividing $3 \cdot 2^{m}$. Moreover $n$ divides $2 a_{m}+a_{m+1}$. Hence we must have $x_{a_{1}}<x_{a_{2}}<x_{a_{3}}<\ldots$ which is not possible as $a_{m}$ 's can take on only finitely many values.

solution_match: # Solution 1.


solution:
Let $E=\{n / 3, n / 2,2 n / 3\} \cap\{1,2, \ldots, n-1\}, D=\{1,2, \ldots, n-1\} \backslash E$, and let $f: D \rightarrow\{1,2, \ldots, n-1\}$ be the function sending $i$ in $D$ to the unique $f(i)$ in $\{1,2, \ldots, n-1\}$ such that $f(i) \equiv-2 i(\bmod n)$.

Then the condition of the problem is that $x_{i}<x_{f(i)}$ for each $i$ in $D$. Since $D$ is a finite set, the integers $x_{1}, x_{2}, \ldots, x_{n-1}$ exist if and only if for each $i$ in $D$ there exists a positive integer $k(i)$ such that $f^{k(i)}(i)$ belongs to $E$. This can be seen as follows:

- If $f^{k}(i)$ does not belong to $E$ for any $k>0$ for some $i$, then there exists $k_{2}>k_{1}>0$ such that $f^{k_{1}}(i)=f^{k_{2}}(i)$, leading to the contradiction $x_{f^{k_{1}(i)}}<$ $x_{f^{k_{2}(i)}}=x_{f^{k_{1}(i)}}$.
- On the other hand, if such $k(i)$ exists for each $i$ in $D$, and if $k_{0}(i)$ denotes the smallest such, then the condition of the problem is satisfied by letting $x_{i}=-k_{0}(i)$ for $i$ in $D$, and $x_{i}=0$ for $i$ in $E$.

In other words, the integers $x_{1}, x_{2}, \ldots, x_{n-1}$ exist if and only if for each $i$ in $D$ there exists a positive integer $k(i)$ such that $(-2)^{k(i)} i \equiv n / 3, n / 2$ or $2 n / 3(\bmod n)$. For $i=1$, this implies that $n=2^{k}$ with $k \geq 1$ or $n=3 \cdot 2^{k}$ with $k \geq 0$. On the other hand, if $n$ has one of these forms, letting $k(i)=k$ does the trick for all $i$ in $D$.

solution_match: # Solution 2.


solution:
Suppose that $x_{1}, x_{2}, \ldots, x_{k-1}$ satisfy the condition of the problem for $n=k$. Let $y_{2 i}=x_{i}$ for $1 \leq i \leq k-1$ and choose $y_{2 i-1}$ for $1 \leq i \leq k$ to be less than $\min \left\{x_{1}, x_{2}, \ldots, x_{k-1}\right\}$. Now suppose that for $n=2 k$ we have $0<i<n, 0<j<n$, $i \neq j, n$ divides $2 i+j$. Then $j$ is even. If $i$ is also even, then $0<i / 2<k, 0<j / 2<k$ and $k$ divides $2(i / 2)+(j / 2)$; hence $y_{i}=x_{i / 2}<x_{j / 2}=y_{j}$. On the other hand, if $i$ is odd, then $y_{i}<\min \left\{x_{1}, x_{2}, \ldots, x_{k-1}\right\} \leq x_{j / 2}=y_{j}$. Therefore, $y_{1}, y_{2}, \ldots, y_{2 k-1}$ satisfy the condition of the problem for $n=2 k$.

Since the condition is vacuous for $n=2$ and $n=3$, it follows that $x_{1}, x_{2}, \ldots, x_{n-1}$ satisfying the condition exist for all $n=2^{k}$ with $k \geq 1$ and $n=3 \cdot 2^{k}$ with $k \geq 0$.

Now suppose that $x_{1}, x_{2}, \ldots, x_{n-1}$ satisfying the condition of the problem exist for $n=2^{k} m$ where $k$ is a nonnegative integer and $m>3$ is an odd number. Let $b_{0}=2^{k}$ and let $b_{i+1}$ be the remainder of the division of $(-2) b_{i}$ by $n$ for $i \geq 0$. No terms of this sequence is 0 and no two consecutive terms are both equal to $b_{1}$ as $m>3$. On the other hand, as $(-2)^{\phi(m)} \equiv 1(\bmod m)$, we have $b_{\phi(m)} \equiv(-2)^{\phi(m)} 2^{k} \equiv 2^{k} \equiv b_{0}$ $(\bmod n)$, and hence $b_{\phi(m)}=b_{0}$. Since $2 b_{i}+b_{i+1}$ is divisible by $n$ for all $i \geq 0$, we have $x_{b_{0}}<x_{b_{1}}<\cdots<x_{b_{\phi(m)}}=x_{b_{0}}$, a contradiction.

solution_match: # Solution 3.


problem:
Let $n$ be a positive integer. We have $n$ boxes where each box contains a nonnegative number of pebbles. In each move we are allowed to take two pebbles from a box we choose, throw away one of the pebbles and put the other pebble in another box we choose. An initial configuration of pebbles is called solvable if it is possible to reach a configuration with no empty box, in a finite (possibly zero) number of moves. Determine all initial configurations of pebbles which are not solvable, but become solvable when an additional pebble is added to a box, no matter which box is chosen.

Proposed by Dan Schwarz, ROU

The answer is any configuration with $2 n-2$ pebbles which has even numbers of pebbles in each box.

solution:
Number the boxes from 1 through $n$ and denote a configuration by $x=\left(x_{1}, x_{2}, \ldots, x_{n}\right)$ where $x_{i}$ is the number of pebbles in the $i$ th box. Let

$$
D(x)=\sum_{i=1}^{n}\left\lfloor\frac{x_{i}-1}{2}\right\rfloor
$$

for a configuration $x$. We can rewrite this in the form

$$
D(x)=\frac{1}{2} N(x)-n+\frac{1}{2} O(x)
$$

where $N(x)$ is the total number of pebbles and $O(x)$ is the number of boxes with an odd number of pebbles for the configuration $x$.

Note that a move either leaves $D$ the same (if it is made into a box containing an even number of pebbles) or decreases it by 1 (if it is made into a box with an odd number of pebbles). As $D$ is nonnegative for any configuration which does not have any empty boxes, it is also nonnegative for any solvable configuration. On the other hand, if a configuration has nonnegative $D$, then making $m_{i}=\left\lfloor\left(x_{i}-1\right) / 2\right\rfloor$ moves from the $i$ th box into $m_{i}$ empty boxes for each $i$ with $m_{i}>0$ fills all boxes as $D(x) \geq 0$ means $\sum_{m_{i}>0} m_{i} \geq$ (number of empty boxes).

As $N(x)$ and $O(x)$ have the same parity, a configuration $x$ is solvable exactly when $O(x) \geq 2 n-N(x)$, and unsolvable exactly when $O(x) \leq 2 n-2-N(x)$. In particular, any configuration with $2 n-1$ pebbles is solvable, and a configuration with $2 n-2$ pebbles is unsolvable if and only if all boxes contain even numbers of pebbles.

Suppose that $x^{\prime}$ is obtained from $x$ by adding a pebble in some box. Then $O\left(x^{\prime}\right)=$ $O(x)+1$ or $O\left(x^{\prime}\right)=O(x)-1$. If $x$ is unsolvable and $x^{\prime}$ is solvable, then we must have $O(x) \leq 2 n-2-N(x)$ and $O\left(x^{\prime}\right) \geq 2 n-N\left(x^{\prime}\right)=2 n-1-N(x)$, and hence $O\left(x^{\prime}\right)=O(x)+1$. That is, the pebble must be added to a box with an even number of pebbles. This can be the case irrespective of where the pebble is added only if all boxes contain even numbers of pebbles, and $0=O(x) \leq 2 n-2-N(x)$ and $1=O\left(x^{\prime}\right) \geq 2 n-1-N(x)$; that is, $N(x)=2 n-2$.

solution_match: Solution 1.


solution:
Let $x$ be a configuration and $\tilde{x}$ be another configuration obtained from $x$ by removing two pebbles from a box and depositing them in another box.
Claim 1: $\tilde{x}$ is solvable if and only if $x$ is solvable.
Let us call two configurations equivalent if they have the same total number of pebbles and parities of the number of pebbles in the corresponding boxes are the same. (It does not matter whether we consider this equivalence for a fixed ordering of the boxes or up to permutation.) From Claim 1 it follows that two equivalent configurations are both solvable or both unsolvable. In particular, any configuration with $2 n-1$ or more pebbles is solvable, because it is equivalent to a configuration with no empty boxes.

Let us a call a configuration with all boxes containing two or fewer pebbles scant. Every unsolvable configuration is equivalent to a scant configuration.

Claim 2: A scant configuration is solvable if and only if it contains no empty boxes.
By Claim 1 and Claim 2, addition of a pebble to a scant unsolvable configuration makes it solvable if and only if the configuration has exactly one empty box and the pebble is added to the empty box or to a box containing two pebbles. Hence, the addition of a pebble makes an unsolvable scant configuration into a solvable configuration irrespective of where it is added if and only if all boxes have even numbers of pebbles and exactly one of them is empty. Therefore, the addition of a pebble makes an unsolvable configuration into a solvable one irrespective of where the pebble is added if and only if the configuration has $2 n-2$ pebbles and all boxes have even numbers of pebbles.

Proof of Claim 1: Suppose that the two pebbles were moved from box $B$ in $x$ to box $\tilde{B}$ in $\tilde{x}$, and $x$ is solvable. Then we perform exactly the same sequence of moves for $\tilde{x}$ as we did for $x$ except that instead of the first move that is made out of $B$ we make a move from $\tilde{B}$ (into the same box), and if there was no move from $B$, then at the end we make a move from $\tilde{B}$ to $B$ in case $B$ is now empty.

Proof of Claim 2: Any move from a scant configuration either leaves the number of empty boxes the same and the resulting configuration is also scant (if it is made into an empty box), or increases the number of empty boxes by one (if it is made into a nonempty box). In the second case, if the move was made into a box containing one pebble, then the resulting configuration is still scant. On the other hand, if it is made into a box containing two pebbles, then the resulting configuration is equivalent to the scant configuration which has one pebble in the box the move was made into and exactly the same number of pebbles in all other boxes as the original configuration. Therefore, any sequence of move from a scant configuration results in a configuration with more or the same number of empty boxes.

solution_match: Solution 2.


problem:
Determine all functions $f: \mathbb{R} \rightarrow \mathbb{R}$ satisfying the condition

$$
f\left(y^{2}+2 x f(y)+f(x)^{2}\right)=(y+f(x))(x+f(y))
$$

for all real numbers $x$ and $y$.
Proposed by Daniël Kroes, NLD
The answer is the functions $f(x)=x, f(x)=-x$ and $f(x)=\frac{1}{2}-x$.

solution:
It can be easily checked that the functions $f(x)=x, f(x)=-x$ and $f(x)=\frac{1}{2}-x$ satisfy the given condition. We will show that these are the only functions doing so. Let $y=-f(x)$ in the original equation to obtain

$$
f\left(2 f(x)^{2}+2 x f(-f(x))\right)=0
$$

for all $x$. In particular, 0 is a value of $f$. Suppose that $u$ and $v$ are such that $f(u)=0=f(v)$. Plugging $x=u$ or $v$ and $y=u$ or $v$ in the original equations we get $f\left(u^{2}\right)=u^{2}, f\left(u^{2}\right)=u v, f\left(v^{2}\right)=u v$ and $f\left(v^{2}\right)=v^{2}$. We conclude that $u^{2}=u v=v^{2}$ and hence $u=v$. So there is exactly one $a$ mapped to 0 , and

$$
f(x)^{2}+x f(-f(x))=\frac{a}{2}
$$

for all $x$.
Suppose that $f\left(x_{1}\right)=f\left(x_{2}\right) \neq 0$ for some $x_{1}$ and $x_{2}$. Using (*) we obtain $x_{1} f\left(-f\left(x_{1}\right)\right)=x_{2} f\left(-f\left(x_{2}\right)\right)=x_{2} f\left(-f\left(x_{1}\right)\right)$ and hence either $x_{1}=x_{2}$ or $f\left(x_{1}\right)=$ $f\left(x_{2}\right)=-a$. In the second case, letting $x=a$ and $y=x_{1}$ in the original equation we get $f\left(x_{1}^{2}-2 a^{2}\right)=0$, hence $x_{1}^{2}-2 a^{2}=a$. Similarly, $x_{2}^{2}-2 a^{2}=a$, and it follows that $x_{1}=x_{2}$ or $x_{1}=-x_{2}$ in this case.

Using the symmetry of the original equation we have

$$
f\left(f(x)^{2}+y^{2}+2 x f(y)\right)=(x+f(y))(y+f(x))=f\left(f(y)^{2}+x^{2}+2 y f(x)\right)
$$

for all $x$ and $y$. Suppose $f(x)^{2}+y^{2}+2 x f(y) \neq f(y)^{2}+x^{2}+2 y f(x)$ for some $x$ and $y$. Then by the observations above, $(x+f(y))(y+f(x)) \neq 0$ and $f(x)^{2}+y^{2}+2 x f(y)=$ $-\left(f(y)^{2}+x^{2}+2 y f(x)\right)$. But these conditions are contradictory as the second one can be rewritten as $(f(x)+y)^{2}+(f(y)+x)^{2}=0$.

Therefore from $\left({ }^{* *}\right)$ now it follows that

$$
f(x)^{2}+y^{2}+2 x f(y)=f(y)^{2}+x^{2}+2 y f(x)
$$

for all $x$ and $y$. In particular, letting $y=0$ we obtain $f(x)^{2}=(f(0)-x)^{2}$ for all $x$. Let $f(x)=s(x)(f(0)-x)$ where $s: \mathbf{R} \rightarrow\{1,-1\}$. Plugging this in $\left({ }^{* * *}\right)$ gives

$$
x(y s(y)+f(0)(1-s(y))=y(x s(x)+f(0)(1-s(x)))
$$

for all $x$ and $y$. So $s(x)+f(0)(1-s(x)) / x$ must be constant for $x \neq 0$.

If $f(0)=0$ it follows that $s(x)$ is constant for $x \neq 0$, and therefore either $f(x)=x$ for all $x$ or $f(x)=-x$ for all $x$. Suppose that $f(0) \neq 0$. If $s(x)$ is -1 for all $x \neq 0$, then $-1+2 f(0) / x$ must be constant for all $x \neq 0$, which is not possible. On the other hand, if there exist nonzero $x$ and $y$ such that $s(x)=-1$ and $s(y)=1$, then $-1+2 f(0) / x=1$. That is, there can be only one such $x$, that $x$ is $f(0)$, and hence $f(x)=f(0)-x$ for all $x$. Putting this back in the original equation gives $2 f(0)^{2}=f(0)$ and hence $f(0)=1 / 2$. We are done.

## Remark:

The following line of reasoning or a variant of it can be used between $\left({ }^{*}\right)$ and $\left({ }^{* * *}\right)$ :
Suppose that $f\left(x_{1}\right)=f\left(x_{2}\right) \neq 0$ for some $x_{1}$ and $x_{2}$. Then from $\left(^{*}\right)$ it follows that $x_{1} f\left(-f\left(x_{1}\right)\right)=x_{2} f\left(-f\left(x_{2}\right)\right)=x_{2} f\left(-f\left(x_{1}\right)\right)$ and hence either $x_{1}=x_{2}$ or $f\left(x_{1}\right)=$ $f\left(x_{2}\right)=-a$. In the second case, using $\left(^{*}\right)$ again we obtain $a^{2}=a / 2$ and therefore $a=$ $1 / 2$. Now letting $x=1 / 2$ in the original equation gives $f\left(y^{2}+f(y)\right)=y(f(y)+1 / 2)$ for all $y$. From this letting $y=0$ we obtain $f(0)=1 / 2$, and letting $f(y)=-1 / 2$ we obtain $f\left(y^{2}-1 / 2\right)=0$ and $y^{2}=1$. To summarize, $f\left(x_{1}\right)=f\left(x_{2}\right) \neq 0$ implies either $x_{1}=x_{2}$ or $x_{1}, x_{2} \in\{1,-1\}$ and $f(1)=f(-1)=-1 / 2, f(1 / 2)=0, f(0)=1 / 2$.

Using the symmetry of the original equation we have

$$
f\left(f(x)^{2}+y^{2}+2 x f(y)\right)=(x+f(y))(y+f(x))=f\left(f(y)^{2}+x^{2}+2 y f(x)\right)
$$

for all $x$ and $y$. Let $y=0$. Then

$$
f\left(f(x)^{2}+2 x f(0)\right)=f\left(f(0)^{2}+x^{2}\right)
$$

for all $x$. If $f(x)^{2}+2 x f(0) \neq f(0)^{2}+x^{2}$ for some $x$, then by the observation above we must have $f(1 / 2)=0, f(0)=1 / 2$ and $f(x)^{2}+2 x f(0)=-\left(f(0)^{2}+x^{2}\right)$. We can rewrite this as $f(x)^{2}+(f(0)+x)^{2}=0$ to obtain $x=1 / 2$ and $f(0)=-x=-1 / 2$, which contradicts $f(0)=1 / 2$. So we conclude that $f(x)^{2}+2 x f(0)=f(0)^{2}+x^{2}$ for all $x$. This implies $f(x)^{2}=(f(0)-x)^{2}$ for all $x$. In particular, the second case considered above is not possible as $(f(0)-1)^{2}=f(1)=f(-1)=(f(0)+1)^{2}$ means $f(0)=0$, contradicting $f(0)=1 / 2$. Therefore $f$ is injective and from $\left({ }^{* *}\right)$ now it follows that

$$
f(x)^{2}+y^{2}+2 x f(y)=f(y)^{2}+x^{2}+2 y f(x)
$$

for all $x$ and $y$.

solution_match: # Solution.