Let $H=\left\{\lfloor i \sqrt{2}\rfloor: i \in \mathbb{Z}_{>0}\right\}=\{1,2,4,5,7, \ldots\}$, and let $n$ be a positive integer. Prove that there exists a constant $C$ such that, if $A \subset\{1,2, \ldots, n\}$ satisfies $|A| \geqslant C \sqrt{n}$, then there exist $a, b \in A$ such that $a-b \in H$.  (Brazil)

Solution: First, observe that if $n$ is a positive integer, then $n \in H$ exactly when  $$ \left\{\frac{n}{\sqrt{2}}\right\}>1-\frac{1}{\sqrt{2}} . $$  To see why, observe that $n \in H$ if and only if $0<i \sqrt{2}-n<1$ for some $i \in \mathbb{Z}_{>0}$. In other words, $0<i-n / \sqrt{2}<1 / \sqrt{2}$, which is equivalent to (1).  Now, write $A=\left\{a_{1}<a_{2}<\cdots<a_{k}\right\}$, where $k=|A|$. Observe that the set of differences is not altered by shifting $A$, so we may assume that $A \subseteq\{0,1, \ldots, n-1\}$ with $a_{1}=0$.  From (1), we learn that $\left\{a_{i} / \sqrt{2}\right\}<1-1 / \sqrt{2}$ for each $i>1$ since $a_{i}-a_{1} \notin H$. Furthermore, we must have $\left\{a_{i} / \sqrt{2}\right\}<\left\{a_{j} / \sqrt{2}\right\}$ whenever $i<j$; otherwise, we would have  $$ -\left(1-\frac{1}{\sqrt{2}}\right)<\left\{\frac{a_{j}}{\sqrt{2}}\right\}-\left\{\frac{a_{i}}{\sqrt{2}}\right\}<0 . $$  Since $\left\{\left(a_{j}-a_{i}\right) / \sqrt{2}\right\}=\left\{a_{j} / \sqrt{2}\right\}-\left\{a_{i} / \sqrt{2}\right\}+1$, this implies that $\left\{\left(a_{j}-a_{i}\right) / \sqrt{2}\right\}>1 / \sqrt{2}>$ $1-1 / \sqrt{2}$, contradicting (1).  Now, we have a sequence $0=a_{1}<a_{2}<\cdots<a_{k}<n$, with  $$ 0=\left\{\frac{a_{1}}{\sqrt{2}}\right\}<\left\{\frac{a_{2}}{\sqrt{2}}\right\}<\cdots<\left\{\frac{a_{k}}{\sqrt{2}}\right\}<1-\frac{1}{\sqrt{2}} . $$  We use the following fact: for any $d \in \mathbb{Z}$, we have  $$ \left\{\frac{d}{\sqrt{2}}\right\}>\frac{1}{2 d \sqrt{2}} $$  To see why this is the case, let $h=\lfloor d / \sqrt{2}\rfloor$, so $\{d / \sqrt{2}\}=d / \sqrt{2}-h$. Then  $$ \left\{\frac{d}{\sqrt{2}}\right\}\left(\frac{d}{\sqrt{2}}+h\right)=\frac{d^{2}-2 h^{2}}{2} \geqslant \frac{1}{2} $$  since the numerator is a positive integer. Because $d / \sqrt{2}+h<2 d / \sqrt{2}$, inequality (2) follows. Let $d_{i}=a_{i+1}-a_{i}$, for $1 \leqslant i<k$. Then $\left\{a_{i+1} / \sqrt{2}\right\}-\left\{a_{i} / \sqrt{2}\right\}=\left\{d_{i} / \sqrt{2}\right\}$, and we have  $$ 1-\frac{1}{\sqrt{2}}>\sum_{i}\left\{\frac{d_{i}}{\sqrt{2}}\right\}>\frac{1}{2 \sqrt{2}} \sum_{i} \frac{1}{d_{i}} \geqslant \frac{(k-1)^{2}}{2 \sqrt{2}} \frac{1}{\sum_{i} d_{i}}>\frac{(k-1)^{2}}{2 \sqrt{2}} \cdot \frac{1}{n} . $$  Here, the first inequality holds because $\left\{a_{k} / \sqrt{2}\right\}<1-1 / \sqrt{2}$, the second follows from (2), the third follows from an easy application of the AM-HM inequality (or Cauchy-Schwarz), and the fourth follows from the fact that $\sum_{i} d_{i}=a_{k}<n$.  Rearranging this, we obtain  $$ \sqrt{2 \sqrt{2}-2} \cdot \sqrt{n}>k-1 $$  which provides the required bound on $k$.


Solution: Let $\alpha=2+\sqrt{2}$, so $(1 / \alpha)+(1 / \sqrt{2})=1$. Thus, $J=\left\{\lfloor i \alpha\rfloor: i \in \mathbb{Z}_{>0}\right\}$ is the complementary Beatty sequence to $H$ (in other words, $H$ and $J$ are disjoint with $H \cup J=\mathbb{Z}_{>0}$ ). Write $A=\left\{a_{1}<a_{2}<\cdots<a_{k}\right\}$. Suppose that $A$ has no differences in $H$, so all its differences are in $J$ and we can set $a_{i}-a_{1}=\left\lfloor\alpha b_{i}\right\rfloor$ for $b_{i} \in \mathbb{Z}_{>0}$.  For any $j>i$, we have $a_{j}-a_{i}=\left\lfloor\alpha b_{j}\right\rfloor-\left\lfloor\alpha b_{i}\right\rfloor$. Because $a_{j}-a_{i} \in J$, we also have $a_{j}-a_{i}=\lfloor\alpha t\rfloor$ for some positive integer $t$. Thus, $\lfloor\alpha t\rfloor=\left\lfloor\alpha b_{j}\right\rfloor-\left\lfloor\alpha b_{i}\right\rfloor$. The right hand side must equal either $\left\lfloor\alpha\left(b_{j}-b_{i}\right)\right\rfloor$ or $\left\lfloor\alpha\left(b_{j}-b_{i}\right)\right\rfloor-1$, the latter of which is not a member of $J$ as $\alpha>2$. Therefore, $t=b_{j}-b_{i}$ and so we have $\left\lfloor\alpha b_{j}\right\rfloor-\left\lfloor\alpha b_{i}\right\rfloor=\left\lfloor\alpha\left(b_{j}-b_{i}\right)\right\rfloor$.  For $1 \leqslant i<k$ we now put $d_{i}=b_{i+1}-b_{i}$, and we have  $$ \left\lfloor\alpha \sum_{i} d_{i}\right\rfloor=\left\lfloor\alpha b_{k}\right\rfloor=\sum_{i}\left\lfloor\alpha d_{i}\right\rfloor ; $$  that is, $\sum_{i}\left\{\alpha d_{i}\right\}<1$. We also have  $$ 1+\left\lfloor\alpha \sum_{i} d_{i}\right\rfloor=1+a_{k}-a_{1} \leqslant a_{k} \leqslant n $$  so $\sum_{i} d_{i} \leqslant n / \alpha$. With the above inequalities, an argument similar to (3) (which uses the fact that $\{\alpha d\}=$ $\{d \sqrt{2}\}>1 /(2 d \sqrt{2})$ for positive integers $d)$ proves that $1>\left((k-1)^{2} /(2 \sqrt{2})\right)(\alpha / n)$, which again rearranges to give  $$ \sqrt{2 \sqrt{2}-2} \cdot \sqrt{n}>k-1 $$  Comment. The use of Beatty sequences in Solution 2 is essentially a way to bypass (1). Both Solutions 1 and 2 use the fact that $\sqrt{2}<2$; the statement in the question would still be true if $\sqrt{2}$ did not have this property (for instance, if it were replaced with $\alpha$ ), but any argument along the lines of Solutions 1 or 2 would be more complicated.


Solution: Again, define $J=\mathbb{Z}_{>0} \backslash H$, so all differences between elements of $A$ are in $J$. We start by making the following observation. Suppose we have a set $B \subseteq\{1,2, \ldots, n\}$ such that all of the differences between elements of $B$ are in $H$. Then $|A| \cdot|B| \leqslant 2 n$.  To see why, observe that any two sums of the form $a+b$ with $a \in A, b \in B$ are different; otherwise, we would have $a_{1}+b_{1}=a_{2}+b_{2}$, and so $\left|a_{1}-a_{2}\right|=\left|b_{2}-b_{1}\right|$. However, then the left hand side is in $J$ whereas the right hand side is in $H$. Thus, $\{a+b: a \in A, b \in B\}$ is a set of size $|A| \cdot|B|$ all of whose elements are no greater than $2 n$, yielding the claimed inequality.  With this in mind, it suffices to construct a set $B$, all of whose differences are in $H$ and whose size is at least $C^{\prime} \sqrt{n}$ for some constant $C^{\prime}>0$.  To do so, we will use well-known facts about the negative Pell equation $X^{2}-2 Y^{2}=-1$; in particular, that there are infinitely many solutions and the values of $X$ are given by the recurrence $X_{1}=1, X_{2}=7$ and $X_{m}=6 X_{m-1}-X_{m-2}$. Therefore, we may choose $X$ to be a solution with $\sqrt{n} / 6<X \leqslant \sqrt{n}$.  Now, we claim that we may choose $B=\{X, 2 X, \ldots,\lfloor(1 / 3) \sqrt{n}\rfloor X\}$. Indeed, we have  $$ \left(\frac{X}{\sqrt{2}}-Y\right)\left(\frac{X}{\sqrt{2}}+Y\right)=\frac{-1}{2} $$  and so  $$ 0>\left(\frac{X}{\sqrt{2}}-Y\right) \geqslant \frac{-3}{\sqrt{2 n}}, $$  from which it follows that $\{X / \sqrt{2}\}>1-(3 / \sqrt{2 n})$. Combined with (1), this shows that all differences between elements of $B$ are in $H$.  Comment. Some of the ideas behind Solution 3 may be used to prove that the constant $C=\sqrt{2 \sqrt{2}-2}$ (from Solutions 1 and 2) is optimal, in the sense that there are arbitrarily large values of $n$ and sets $A_{n} \subseteq\{1,2, \ldots, n\}$ of size roughly $C \sqrt{n}$, all of whose differences are contained in $J$.  To see why, choose $X$ to come from a sufficiently large solution to the Pell equation $X^{2}-2 Y^{2}=1$, so $\{X / \sqrt{2}\} \approx 1 /(2 X \sqrt{2})$. In particular, $\{X\},\{2 X\}, \ldots,\{[2 X \sqrt{2}(1-1 / \sqrt{2})\rfloor X\}$ are all less than $1-1 / \sqrt{2}$. Thus, by (1) any positive integer of the form $i X$ for $1 \leqslant i \leqslant\lfloor 2 X \sqrt{2}(1-1 / \sqrt{2})\rfloor$ lies in $J$.  Set $n \approx 2 X^{2} \sqrt{2}(1-1 / \sqrt{2})$. We now have a set $A=\{i X: i \leqslant\lfloor 2 X \sqrt{2}(1-1 / \sqrt{2})\rfloor\}$ containing roughly $2 X \sqrt{2}(1-1 / \sqrt{2})$ elements less than or equal to $n$ such that all of the differences lie in $J$, and we can see that $|A| \approx C \sqrt{n}$ with $C=\sqrt{2 \sqrt{2}-2}$.


Solution: As in   Choose $Y$ to be a solution to the Pell-like equation $X^{2}-2 Y^{2}= \pm 1$; such solutions are given by the recurrence $Y_{1}=1, Y_{2}=2$ and $Y_{m}=2 Y_{m-1}+Y_{m-2}$, and so we can choose $Y$ such that $n /(3 \sqrt{2})<Y \leqslant n / \sqrt{2}$. Furthermore, it is known that for such a $Y$ and for $1 \leqslant x<Y$,  $$ \{x \sqrt{2}\}+\{(Y-x) \sqrt{2}\}=\{Y / \sqrt{2}\} $$  if $X^{2}-2 Y^{2}=1$, and  $$ \{x \sqrt{2}\}+\{(Y-x) \sqrt{2}\}=1+\{Y / \sqrt{2}\} $$  if $X^{2}-2 Y^{2}=-1$. Indeed, this is a statement of the fact that $X / Y$ is a best rational approximation to $\sqrt{2}$, from below in the first case and from above in the second.  Now, consider the sequence $\{\sqrt{2}\},\{2 \sqrt{2}\}, \ldots,\{(Y-1) \sqrt{2}\}$. The Erdős-Szekeres theorem tells us that this sequence has a monotone subsequence with at least $\sqrt{Y-2}+1>\sqrt{Y}$ elements; if that subsequence is decreasing, we may reflect (using (4) or (5)) to ensure that it is increasing. Call the subsequence $\left\{y_{1} \sqrt{2}\right\},\left\{y_{2} \sqrt{2}\right\}, \ldots,\left\{y_{t} \sqrt{2}\right\}$ for $t>\sqrt{Y}$.  Now, set $B=\left\{\left\lfloor y_{i} \sqrt{2}\right\rfloor: 1 \leqslant i \leqslant t\right\}$. We have $\left\lfloor y_{j} \sqrt{2}\right\rfloor-\left\lfloor y_{i} \sqrt{2}\right\rfloor=\left\lfloor\left(y_{j}-y_{i}\right) \sqrt{2}\right\rfloor$ for $i<j$ (because the corresponding inequality for the fractional parts holds by the ordering assumption on the $\left\{y_{i} \sqrt{2}\right\}$ ), which means that all differences between elements of $B$ are indeed in $H$. Since $|B|>\sqrt{Y}>\sqrt{n} / \sqrt{3 \sqrt{2}}$, this is the required set.  Comment. Any solution to this problem will need to use the fact that $\sqrt{2}$ cannot be approximated well by rationals, either directly or implicitly (for example, by using facts about solutions to Pelllike equations). If $\sqrt{2}$ were replaced by a value of $\theta$ with very good rational approximations (from below), then an argument along the lines of Solution 3 would give long arithmetic progressions in $\{\lfloor i \theta\rfloor: 0 \leqslant i<n\}$ (with initial term 0 ) for certain values of $n$.


Prove that there is a constant $c>0$ and infinitely many positive integers $n$ with the following property: there are infinitely many positive integers that cannot be expressed as the sum of fewer than $c n \log (n)$ pairwise coprime $n^{\text {th }}$ powers. (Canada)

Solution: Suppose, for an integer $n$, that we can find another integer $N$ satisfying the following property: $n$ is divisible by $\varphi\left(p^{e}\right)$ for every prime power $p^{e}$ exactly dividing $N$. This property ensures that all $n^{\text {th }}$ powers are congruent to 0 or 1 modulo each such prime power $p^{e}$, and hence that any sum of $m$ pairwise coprime $n^{\text {th }}$ powers is congruent to $m$ or $m-1$ modulo $p^{e}$, since at most one of the $n^{\text {th }}$ powers is divisible by $p$. Thus, if $k$ denotes the number of distinct prime factors of $N$, we find by the Chinese Remainder Theorem at most $2^{k} m$ residue classes modulo $N$ which are sums of at most $m$ pairwise coprime $n^{\text {th }}$ powers. In particular, if $N>2^{k} m$ then there are infinitely many positive integers not expressible as a sum of at most $m$ pairwise coprime $n^{\text {th }}$ powers.  It thus suffices to prove that there are arbitrarily large pairs $(n, N)$ of integers satisfying $(\dagger)$ such that  $$ N>c \cdot 2^{k} n \log (n) $$  for some positive constant $c$. We construct such pairs as follows. Fix a positive integer $t$ and choose (distinct) prime numbers $p \mid 2^{2^{t-1}}+1$ and $q \mid 2^{2^{t}}+1$; we set $N=p q$. It is well-known that $2^{t} \mid p-1$ and $2^{t+1} \mid q-1$, hence  $$ n=\frac{(p-1)(q-1)}{2^{t}} $$  is an integer and the pair $(n, N)$ satisfies $(\dagger)$. Estimating the size of $N$ and $n$ is now straightforward. We have  $$ \log _{2}(n) \leqslant 2^{t-1}+2^{t}-t<2^{t+1}<2 \cdot \frac{N}{n} $$  which rearranges to  $$ N>\frac{1}{8} \cdot 2^{2} n \log _{2}(n) $$  and so we are done if we choose $c<\frac{1}{8 \log (2)} \approx 0.18$. Comment 1. The trick in the above solution was to find prime numbers $p$ and $q$ congruent to 1 modulo some $d=2^{t}$ and which are not too large. An alternative way to do this is via Linnik's Theorem, which says that there are absolute constants $b$ and $L>1$ such that for any coprime integers $a$ and $d$, there is a prime congruent to $a$ modulo $d$ and of size $\leqslant b d^{L}$. If we choose some $d$ not divisible by 3 and choose two distinct primes $p, q \leqslant b \cdot(3 d)^{L}$ congruent to 1 modulo $d$ (and, say, distinct modulo 3 ), then we obtain a pair $(n, N)$ satisfying $(\dagger)$ with $N=p q$ and $n=\frac{(p-1)(q-1)}{d}$. A straightforward computation shows that  $$ N>C n^{1+\frac{1}{2 L-1}} $$  for some constant $C$, which is in particular larger than any $c \cdot 2^{2} n \log (n)$ for $p$ large. Thus, the statement of the problem is true for any constant $c$. More strongly, the statement of the problem is still true when $c n \log (n)$ is replaced by $n^{1+\delta}$ for a sufficiently small $\delta>0$.  Solution 2, obtaining better bounds. As in the preceding solution, we seek arbitrarily large pairs of integers $n$ and $N$ satisfying ( $\dagger$ ) such that $N>c 2^{k} n \log (n)$.  This time, to construct such pairs, we fix an integer $x \geqslant 4$, set $N$ to be the lowest common multiple of $1,2, \ldots, 2 x$, and set $n$ to be twice the lowest common multiple of $1,2, \ldots, x$. The pair $(n, N)$ does indeed satisfy the condition, since if $p^{e}$ is a prime power divisor of $N$ then $\frac{\varphi\left(p^{e}\right)}{2} \leqslant x$ is a factor of $\frac{n}{2}=\operatorname{lcm}_{r \leqslant x}(r)$.  Now $2 N / n$ is the product of all primes having a power lying in the interval $(x, 2 x]$, and hence $2 N / n>x^{\pi(2 x)-\pi(x)}$. Thus for sufficiently large $x$ we have  $$ \log \left(\frac{2 N}{2^{\pi(2 x)} n}\right)>(\pi(2 x)-\pi(x)) \log (x)-\log (2) \pi(2 x) \sim x $$  using the Prime Number Theorem $\pi(t) \sim t / \log (t)$. On the other hand, $n$ is a product of at most $\pi(x)$ prime powers less than or equal to $x$, and so we have the upper bound  $$ \log (n) \leqslant \pi(x) \log (x) \sim x $$  again by the Prime Number Theorem. Combined with the above inequality, we find that for any $\epsilon>0$, the inequality  $$ \log \left(\frac{N}{2^{\pi(2 x)} n}\right)>(1-\epsilon) \log (n) $$  holds for sufficiently large $x$. Rearranging this shows that  $$ N>2^{\pi(2 x)} n^{2-\epsilon}>2^{\pi(2 x)} n \log (n) $$  for all sufficiently large $x$ and we are done. Comment 2. The stronger bound $N>2^{\pi(2 x)} n^{2-\epsilon}$ obtained in the above proof of course shows that infinitely many positive integers cannot be written as a sum of at most $n^{2-\epsilon}$ pairwise coprime $n^{\text {th }}$ powers.  By refining the method in Solution 2, these bounds can be improved further to show that infinitely many positive integers cannot be written as a sum of at most $n^{\alpha}$ pairwise coprime $n^{\text {th }}$ powers for any positive $\alpha>0$. To do this, one fixes a positive integer $d$, sets $N$ equal to the product of the primes at most $d x$ which are congruent to 1 modulo $d$, and $n=d \mathrm{lcm}_{r \leqslant x}(r)$. It follows as in Solution 2 that $(n, N)$ satisfies $(\dagger)$.  Now the Prime Number Theorem in arithmetic progressions provides the estimates $\log (N) \sim \frac{d}{\varphi(d)} x$, $\log (n) \sim x$ and $\pi(d x) \sim \frac{d x}{\log (x)}$ for any fixed $d$. Combining these provides a bound  $$ N>2^{\pi(d x)} n^{d / \varphi(d)-\epsilon} $$  for any positive $\epsilon$, valid for $x$ sufficiently large. Since the ratio $\frac{d}{\varphi(d)}$ can be made arbitrarily large by a judicious choice of $d$, we obtain the $n^{\alpha}$ bound claimed.  Comment 3. While big results from analytic number theory such as the Prime Number Theorem or Linnik's Theorem certainly can be used in this problem, they do not seem to substantially simplify matters: all known solutions involve first reducing to condition ( $\dagger$ ), and even then analytic results do not make it clear how to proceed. For this reason, we regard this problem as suitable for the IMO.  Rather than simplifying the problem, what nonelementary results from analytic number theory allow one to achieve is a strengthening of the main bound, typically replacing the $n \log (n)$ growth with a power $n^{1+\delta}$. However, we believe that such stronger bounds are unlikely to be found by students in the exam.  The strongest bound we know how to achieve using purely elementary methods is a bound of the form $N>2^{k} n \log (n)^{M}$ for any positive integer $M$. This is achieved by a variant of the argument in Solution 1, choosing primes $p_{0}, \ldots, p_{M}$ with $p_{i} \mid 2^{2^{t+i-1}}+1$ and setting $N=\prod_{i} p_{i}$ and $n=$ $2^{-t M} \prod_{i}\left(p_{i}-1\right)$.


Let $a$ and $b$ be two positive integers. Prove that the integer  $$ a^{2}+\left\lceil\frac{4 a^{2}}{b}\right\rceil $$  is not a square. (Here $\lceil z\rceil$ denotes the least integer greater than or equal to $z$.)

Solution: Arguing indirectly, assume that  $$ a^{2}+\left\lceil\frac{4 a^{2}}{b}\right\rceil=(a+k)^{2}, \quad \text { or } \quad\left\lceil\frac{(2 a)^{2}}{b}\right\rceil=(2 a+k) k $$  Clearly, $k \geqslant 1$. In other words, the equation  $$ \left\lceil\frac{c^{2}}{b}\right\rceil=(c+k) k $$  has a positive integer solution $(c, k)$, with an even value of $c$. Choose a positive integer solution of (1) with minimal possible value of $k$, without regard to the parity of $c$. From  $$ \frac{c^{2}}{b}>\left\lceil\frac{c^{2}}{b}\right\rceil-1=c k+k^{2}-1 \geqslant c k $$  and  $$ \frac{(c-k)(c+k)}{b}<\frac{c^{2}}{b} \leqslant\left\lceil\frac{c^{2}}{b}\right\rceil=(c+k) k $$  it can be seen that $c>b k>c-k$, so  $$ c=k b+r \quad \text { with some } 0<r<k $$  By substituting this in (1) we get  $$ \left\lceil\frac{c^{2}}{b}\right\rceil=\left\lceil\frac{(b k+r)^{2}}{b}\right\rceil=k^{2} b+2 k r+\left\lceil\frac{r^{2}}{b}\right\rceil $$  and  $$ (c+k) k=(k b+r+k) k=k^{2} b+2 k r+k(k-r) $$  so  $$ \left\lceil\frac{r^{2}}{b}\right\rceil=k(k-r) $$  Notice that relation (2) provides another positive integer solution of (1), namely $c^{\prime}=r$ and $k^{\prime}=k-r$, with $c^{\prime}>0$ and $0<k^{\prime}<k$. That contradicts the minimality of $k$, and hence finishes the solution.


Solution: Suppose that  $$ a^{2}+\left\lceil\frac{4 a^{2}}{b}\right\rceil=c^{2} $$  with some positive integer $c>a$, so  $$ \begin{aligned} & c^{2}-1<a^{2}+\frac{4 a^{2}}{b} \leqslant c^{2} \\ & 0 \leqslant c^{2} b-a^{2}(b+4)<b \end{aligned} $$  Let $d=c^{2} b-a^{2}(b+4), x=c+a$ and $y=c-a$; then we have $c=\frac{x+y}{2}$ and $a=\frac{x-y}{2}$, and (3) can be re-written as follows:  $$ \begin{aligned} \left(\frac{x+y}{2}\right)^{2} b-\left(\frac{x-y}{2}\right)^{2}(b+4) & =d \\ x^{2}-(b+2) x y+y^{2}+d=0 ; \quad 0 & \leqslant d<b \end{aligned} $$  So, by the indirect assumption, the equation (4) has some positive integer solution $(x, y)$. Fix $b$ and $d$, and take a pair $(x, y)$ of positive integers, satisfying (4), such that $x+y$ is minimal. By the symmetry in (4) we may assume that $x \geqslant y \geqslant 1$.  Now we perform a usual "Vieta jump". Consider (4) as a quadratic equation in variable $x$, and let $z$ be its second root. By the Vieta formulas,  $$ x+z=(b+2) y, \quad \text { and } \quad z x=y^{2}+d, $$  so  $$ z=(b+2) y-x=\frac{y^{2}+d}{x} $$  The first formula shows that $z$ is an integer, and by the second formula $z$ is positive. Hence $(z, y)$ is another positive integer solution of (4). From  $$ \begin{aligned} (x-1)(z-1) & =x z-(x+z)+1=\left(y^{2}+d\right)-(b+2) y+1 \\ & <\left(y^{2}+b\right)-(b+2) y+1=(y-1)^{2}-b(y-1) \leqslant(y-1)^{2} \leqslant(x-1)^{2} \end{aligned} $$  we can see that $z<x$ and therefore $z+y<x+y$. But this contradicts the minimality of $x+y$ among the positive integer solutions of (4).  The activities of the Problem Selection Committee were supported by Trinity College, Cambridge University of Cambridge


Let $\mathbb{Z}$ be the set of integers. Determine all functions $f: \mathbb{Z} \rightarrow \mathbb{Z}$ such that, for all integers $a$ and $b$,  $$ f(2 a)+2 f(b)=f(f(a+b)) $$  (South Africa) Answer: The solutions are $f(n)=0$ and $f(n)=2 n+K$ for any constant $K \in \mathbb{Z}$. Common remarks. Most solutions to this problem first prove that $f$ must be linear, before determining all linear functions satisfying (1).

Solution: Substituting $a=0, b=n+1$ gives $f(f(n+1))=f(0)+2 f(n+1)$. Substituting $a=1, b=n$ gives $f(f(n+1))=f(2)+2 f(n)$.  In particular, $f(0)+2 f(n+1)=f(2)+2 f(n)$, and so $f(n+1)-f(n)=\frac{1}{2}(f(2)-f(0))$. Thus $f(n+1)-f(n)$ must be constant. Since $f$ is defined only on $\mathbb{Z}$, this tells us that $f$ must be a linear function; write $f(n)=M n+K$ for arbitrary constants $M$ and $K$, and we need only determine which choices of $M$ and $K$ work.  Now, (1) becomes  $$ 2 M a+K+2(M b+K)=M(M(a+b)+K)+K $$  which we may rearrange to form  $$ (M-2)(M(a+b)+K)=0 $$  Thus, either $M=2$, or $M(a+b)+K=0$ for all values of $a+b$. In particular, the only possible solutions are $f(n)=0$ and $f(n)=2 n+K$ for any constant $K \in \mathbb{Z}$, and these are easily seen to work.


Solution: Let $K=f(0)$. First, put $a=0$ in (1); this gives  $$ f(f(b))=2 f(b)+K $$  for all $b \in \mathbb{Z}$. Now put $b=0$ in (1); this gives  $$ f(2 a)+2 K=f(f(a))=2 f(a)+K $$  where the second equality follows from (2). Consequently,  $$ f(2 a)=2 f(a)-K $$  for all $a \in \mathbb{Z}$. Substituting (2) and (3) into (1), we obtain  $$ \begin{aligned} f(2 a)+2 f(b) & =f(f(a+b)) \\ 2 f(a)-K+2 f(b) & =2 f(a+b)+K \\ f(a)+f(b) & =f(a+b)+K \end{aligned} $$  Thus, if we set $g(n)=f(n)-K$ we see that $g$ satisfies the Cauchy equation $g(a+b)=$ $g(a)+g(b)$. The solution to the Cauchy equation over $\mathbb{Z}$ is well-known; indeed, it may be proven by an easy induction that $g(n)=M n$ for each $n \in \mathbb{Z}$, where $M=g(1)$ is a constant.  Therefore, $f(n)=M n+K$, and we may proceed as in Solution 1 . Comment 1. Instead of deriving (3) by substituting $b=0$ into (1), we could instead have observed that the right hand side of (1) is symmetric in $a$ and $b$, and thus  $$ f(2 a)+2 f(b)=f(2 b)+2 f(a) $$  Thus, $f(2 a)-2 f(a)=f(2 b)-2 f(b)$ for any $a, b \in \mathbb{Z}$, and in particular $f(2 a)-2 f(a)$ is constant. Setting $a=0$ shows that this constant is equal to $-K$, and so we obtain (3).  Comment 2. Some solutions initially prove that $f(f(n))$ is linear (sometimes via proving that $f(f(n))-3 K$ satisfies the Cauchy equation). However, one can immediately prove that $f$ is linear by substituting something of the form $f(f(n))=M^{\prime} n+K^{\prime}$ into (2).


Solution: Notice first that $b>0$ and $a<0$. Indeed, since $\sum_{i=1}^{2019} u_{i}^{2}=1$, the variables $u_{i}$ cannot be all zero, and, since $\sum_{i=1}^{2019} u_{i}=0$, the nonzero elements cannot be all positive or all negative.  Let $P=\left\{i: u_{i}>0\right\}$ and $N=\left\{i: u_{i} \leqslant 0\right\}$ be the indices of positive and nonpositive elements in the sequence, and let $p=|P|$ and $n=|N|$ be the sizes of these sets; then $p+n=2019$. By the condition $\sum_{i=1}^{2019} u_{i}=0$ we have $0=\sum_{i=1}^{2019} u_{i}=\sum_{i \in P} u_{i}-\sum_{i \in N}\left|u_{i}\right|$, so  $$ \sum_{i \in P} u_{i}=\sum_{i \in N}\left|u_{i}\right| . $$  After this preparation, estimate the sum of squares of the positive and nonpositive elements as follows:  $$ \begin{aligned} & \sum_{i \in P} u_{i}^{2} \leqslant \sum_{i \in P} b u_{i}=b \sum_{i \in P} u_{i}=b \sum_{i \in N}\left|u_{i}\right| \leqslant b \sum_{i \in N}|a|=-n a b ; \\ & \sum_{i \in N} u_{i}^{2} \leqslant \sum_{i \in N}|a| \cdot\left|u_{i}\right|=|a| \sum_{i \in N}\left|u_{i}\right|=|a| \sum_{i \in P} u_{i} \leqslant|a| \sum_{i \in P} b=-p a b . \end{aligned} $$  The sum of these estimates is  $$ 1=\sum_{i=1}^{2019} u_{i}^{2}=\sum_{i \in P} u_{i}^{2}+\sum_{i \in N} u_{i}^{2} \leqslant-(p+n) a b=-2019 a b ; $$  that proves $a b \leqslant \frac{-1}{2019}$. Comment 1. After observing $\sum_{i \in P} u_{i}^{2} \leqslant b \sum_{i \in P} u_{i}$ and $\sum_{i \in N} u_{i}^{2} \leqslant|a| \sum_{i \in P}\left|u_{i}\right|$, instead of $(2,3)$ an alternative continuation is  $$ |a b| \geqslant \frac{\sum_{i \in P} u_{i}^{2}}{\sum_{i \in P} u_{i}} \cdot \frac{\sum_{i \in N} u_{i}^{2}}{\sum_{i \in N}\left|u_{i}\right|}=\frac{\sum_{i \in P} u_{i}^{2}}{\left(\sum_{i \in P} u_{i}\right)^{2}} \sum_{i \in N} u_{i}^{2} \geqslant \frac{1}{p} \sum_{i \in N} u_{i}^{2} $$  (by the AM-QM or the Cauchy-Schwarz inequality) and similarly $|a b| \geqslant \frac{1}{n} \sum_{i \in P} u_{i}^{2}$.


Solution: As in the previous solution we conclude that $a<0$ and $b>0$. For every index $i$, the number $u_{i}$ is a convex combination of $a$ and $b$, so  $$ u_{i}=x_{i} a+y_{i} b \quad \text { with some weights } 0 \leqslant x_{i}, y_{i} \leqslant 1, \text { with } x_{i}+y_{i}=1 \text {. } $$  Let $X=\sum_{i=1}^{2019} x_{i}$ and $Y=\sum_{i=1}^{2019} y_{i}$. From $0=\sum_{i=1}^{2019} u_{i}=\sum_{i=1}^{2019}\left(x_{i} a+y_{i} b\right)=-|a| X+b Y$, we get  $$ |a| X=b Y $$  From $\sum_{i=1}^{2019}\left(x_{i}+y_{i}\right)=2019$ we have  $$ X+Y=2019 $$  The system of linear equations $(4,5)$ has a unique solution:  $$ X=\frac{2019 b}{|a|+b}, \quad Y=\frac{2019|a|}{|a|+b} $$  Now apply the following estimate to every $u_{i}^{2}$ in their sum:  $$ u_{i}^{2}=x_{i}^{2} a^{2}+2 x_{i} y_{i} a b+y_{i}^{2} b^{2} \leqslant x_{i} a^{2}+y_{i} b^{2} $$  we obtain that  $$ 1=\sum_{i=1}^{2019} u_{i}^{2} \leqslant \sum_{i=1}^{2019}\left(x_{i} a^{2}+y_{i} b^{2}\right)=X a^{2}+Y b^{2}=\frac{2019 b}{|a|+b}|a|^{2}+\frac{2019|a|}{|a|+b} b^{2}=2019|a| b=-2019 a b . $$  Hence, $a b \leqslant \frac{-1}{2019}$. Comment 2. The idea behind Solution 2 is the following thought. Suppose we fix $a<0$ and $b>0$, fix $\sum u_{i}=0$ and vary the $u_{i}$ to achieve the maximum value of $\sum u_{i}^{2}$. Considering varying any two of the $u_{i}$ while preserving their sum: the maximum value of $\sum u_{i}^{2}$ is achieved when those two are as far apart as possible, so all but at most one of the $u_{i}$ are equal to $a$ or $b$. Considering a weighted version of the problem, we see the maximum (with fractional numbers of $u_{i}$ having each value) is achieved when $\frac{2019 b}{|a|+b}$ of them are $a$ and $\frac{2019|a|}{|a|+b}$ are $b$.  In fact, this happens in the solution: the number $u_{i}$ is replaced by $x_{i}$ copies of $a$ and $y_{i}$ copies of $b$.


Let $n \geqslant 3$ be a positive integer and let $\left(a_{1}, a_{2}, \ldots, a_{n}\right)$ be a strictly increasing sequence of $n$ positive real numbers with sum equal to 2 . Let $X$ be a subset of $\{1,2, \ldots, n\}$ such that the value of  $$ \left|1-\sum_{i \in X} a_{i}\right| $$  is minimised. Prove that there exists a strictly increasing sequence of $n$ positive real numbers $\left(b_{1}, b_{2}, \ldots, b_{n}\right)$ with sum equal to 2 such that  $$ \sum_{i \in X} b_{i}=1 $$  (New Zealand) Common remarks. In all solutions, we say an index set $X$ is $\left(a_{i}\right)$-minimising if it has the property in the problem for the given sequence $\left(a_{i}\right)$. Write $X^{c}$ for the complement of $X$, and $[a, b]$ for the interval of integers $k$ such that $a \leqslant k \leqslant b$. Note that  $$ \left|1-\sum_{i \in X} a_{i}\right|=\left|1-\sum_{i \in X^{c}} a_{i}\right|, $$  so we may exchange $X$ and $X^{c}$ where convenient. Let  $$ \Delta=\sum_{i \in X^{c}} a_{i}-\sum_{i \in X} a_{i} $$  and note that $X$ is $\left(a_{i}\right)$-minimising if and only if it minimises $|\Delta|$, and that $\sum_{i \in X} a_{i}=1$ if and only if $\Delta=0$.  In some solutions, a scaling process is used. If we have a strictly increasing sequence of positive real numbers $c_{i}$ (typically obtained by perturbing the $a_{i}$ in some way) such that  $$ \sum_{i \in X} c_{i}=\sum_{i \in X^{c}} c_{i} $$  then we may put $b_{i}=2 c_{i} / \sum_{j=1}^{n} c_{j}$. So it suffices to construct such a sequence without needing its sum to be 2 .  The solutions below show various possible approaches to the problem. Solutions 1 and 2 perturb a few of the $a_{i}$ to form the $b_{i}$ (with scaling in the case of Solution 1, without scaling in the case of Solution 2). Solutions 3 and 4 look at properties of the index set $X$. Solution 3 then perturbs many of the $a_{i}$ to form the $b_{i}$, together with scaling. Rather than using such perturbations, Solution 4 constructs a sequence $\left(b_{i}\right)$ directly from the set $X$ with the required properties. Solution 4 can be used to give a complete description of sets $X$ that are $\left(a_{i}\right)$-minimising for some $\left(a_{i}\right)$.

Solution: Without loss of generality, assume $\sum_{i \in X} a_{i} \leqslant 1$, and we may assume strict inequality as otherwise $b_{i}=a_{i}$ works. Also, $X$ clearly cannot be empty.  If $n \in X$, add $\Delta$ to $a_{n}$, producing a sequence of $c_{i}$ with $\sum_{i \in X} c_{i}=\sum_{i \in X^{c}} c_{i}$, and then scale as described above to make the sum equal to 2 . Otherwise, there is some $k$ with $k \in X$ and $k+1 \in X^{c}$. Let $\delta=a_{k+1}-a_{k}$.  - If $\delta>\Delta$, add $\Delta$ to $a_{k}$ and then scale. - If $\delta<\Delta$, then considering $X \cup\{k+1\} \backslash\{k\}$ contradicts $X$ being $\left(a_{i}\right)$-minimising. - If $\delta=\Delta$, choose any $j \neq k, k+1$ (possible since $n \geqslant 3$ ), and any $\epsilon$ less than the least of $a_{1}$ and all the differences $a_{i+1}-a_{i}$. If $j \in X$ then add $\Delta-\epsilon$ to $a_{k}$ and $\epsilon$ to $a_{j}$, then scale; otherwise, add $\Delta$ to $a_{k}$ and $\epsilon / 2$ to $a_{k+1}$, and subtract $\epsilon / 2$ from $a_{j}$, then scale.


Solution: This is similar to   Suppose there exists $1 \leqslant j \leqslant n-1$ such that $j \in X$ but $j+1 \in X^{c}$. Then $a_{j+1}-a_{j} \geqslant \Delta$, because otherwise considering $X \cup\{j+1\} \backslash\{j\}$ contradicts $X$ being $\left(a_{i}\right)$-minimising.  If $a_{j+1}-a_{j}>\Delta$, put  $$ b_{i}= \begin{cases}a_{j}+\Delta / 2, & \text { if } i=j \\ a_{j+1}-\Delta / 2, & \text { if } i=j+1 \\ a_{i}, & \text { otherwise }\end{cases} $$  If $a_{j+1}-a_{j}=\Delta$, choose any $\epsilon$ less than the least of $\Delta / 2, a_{1}$ and all the differences $a_{i+1}-a_{i}$. If $|X| \geqslant 2$, choose $k \in X$ with $k \neq j$, and put  $$ b_{i}= \begin{cases}a_{j}+\Delta / 2-\epsilon, & \text { if } i=j \\ a_{j+1}-\Delta / 2, & \text { if } i=j+1 \\ a_{k}+\epsilon, & \text { if } i=k \\ a_{i}, & \text { otherwise }\end{cases} $$  Otherwise, $\left|X^{c}\right| \geqslant 2$, so choose $k \in X^{c}$ with $k \neq j+1$, and put  $$ b_{i}= \begin{cases}a_{j}+\Delta / 2, & \text { if } i=j \\ a_{j+1}-\Delta / 2+\epsilon, & \text { if } i=j+1 \\ a_{k}-\epsilon, & \text { if } i=k \\ a_{i}, & \text { otherwise }\end{cases} $$  If there is no $1 \leqslant j \leqslant n$ such that $j \in X$ but $j+1 \in X^{c}$, there must be some $1<k \leqslant n$ such that $X=[k, n]$ (certainly $X$ cannot be empty). We must have $a_{1}>\Delta$, as otherwise considering $X \cup\{1\}$ contradicts $X$ being $\left(a_{i}\right)$-minimising. Now put  $$ b_{i}= \begin{cases}a_{1}-\Delta / 2, & \text { if } i=1 \\ a_{n}+\Delta / 2, & \text { if } i=n \\ a_{i}, & \text { otherwise }\end{cases} $$


Solution: Without loss of generality, assume $\sum_{i \in X} a_{i} \leqslant 1$, so $\Delta \geqslant 0$. If $\Delta=0$ we can take $b_{i}=a_{i}$, so now assume that $\Delta>0$.  Suppose that there is some $k \leqslant n$ such that $|X \cap[k, n]|>\left|X^{c} \cap[k, n]\right|$. If we choose the largest such $k$ then $|X \cap[k, n]|-\left|X^{c} \cap[k, n]\right|=1$. We can now find the required sequence $\left(b_{i}\right)$ by starting with $c_{i}=a_{i}$ for $i<k$ and $c_{i}=a_{i}+\Delta$ for $i \geqslant k$, and then scaling as described above.  If no such $k$ exists, we will derive a contradiction. For each $i \in X$ we can choose $i<j_{i} \leqslant n$ in such a way that $j_{i} \in X^{c}$ and all the $j_{i}$ are different. (For instance, note that necessarily $n \in X^{c}$ and now just work downwards; each time an $i \in X$ is considered, let $j_{i}$ be the least element of $X^{c}$ greater than $i$ and not yet used.) Let $Y$ be the (possibly empty) subset of $[1, n]$ consisting of those elements in $X^{c}$ that are also not one of the $j_{i}$. In any case  $$ \Delta=\sum_{i \in X}\left(a_{j_{i}}-a_{i}\right)+\sum_{j \in Y} a_{j} $$  where each term in the sums is positive. Since $n \geqslant 3$ the total number of terms above is at least two. Take a least such term and its corresponding index $i$ and consider the set $Z$ which we form from $X$ by removing $i$ and adding $j_{i}$ (if it is a term of the first type) or just by adding $j$ if it is a term of the second type. The corresponding expression of $\Delta$ for $Z$ has the sign of its least term changed, meaning that the sum is still nonnegative but strictly less than $\Delta$, which contradicts $X$ being $\left(a_{i}\right)$-minimising.


Solution: This uses some similar ideas to   Note that, for two subsets $X, Y$ of $[1, n]$, the following are equivalent:  - $|X \cap[i, n]| \leqslant|Y \cap[i, n]|$ for all $1 \leqslant i \leqslant n$; - $Y$ is at least as large as $X$, and for all $1 \leqslant j \leqslant|Y|$, the $j^{\text {th }}$ largest element of $Y$ is at least as big as the $j^{\text {th }}$ largest element of $X$; - there is an injective function $f: X \rightarrow Y$ such that $f(i) \geqslant i$ for all $i \in X$.  If these equivalent conditions are satisfied, we write $X \leq Y$. We write $X<Y$ if $X \leq Y$ and $X \neq Y$.  Note that if $X<Y$, then $\sum_{i \in X} a_{i}<\sum_{i \in Y} a_{i}$ (the second description above makes this clear). We claim first that, if $n \geqslant 3$ and $X \prec X^{c}$, then there exists $Y$ with $X \prec Y<X^{c}$. Indeed, as $|X| \leqslant\left|X^{c}\right|$, we have $\left|X^{c}\right| \geqslant 2$. Define $Y$ to consist of the largest element of $X^{c}$, together with all but the largest element of $X$; it is clear both that $Y$ is distinct from $X$ and $X^{c}$, and that $X \leq Y \leq X^{c}$, which is what we need.  But, in this situation, we have  $$ \sum_{i \in X} a_{i}<\sum_{i \in Y} a_{i}<\sum_{i \in X^{c}} a_{i} \quad \text { and } \quad 1-\sum_{i \in X} a_{i}=-\left(1-\sum_{i \in X^{c}} a_{i}\right), $$  so $\left|1-\sum_{i \in Y} a_{i}\right|<\left|1-\sum_{i \in X} a_{i}\right|$. Hence if $X$ is $\left(a_{i}\right)$-minimising, we do not have $X \prec X^{c}$, and similarly we do not have $X^{c}<X$.  Considering the first description above, this immediately implies the following Claim. Claim. There exist $1 \leqslant k, \ell \leqslant n$ such that $|X \cap[k, n]|>\frac{n-k+1}{2}$ and $|X \cap[\ell, n]|<\frac{n-\ell+1}{2}$. We now construct our sequence $\left(b_{i}\right)$ using this claim. Let $k$ and $\ell$ be the greatest values satisfying the claim, and without loss of generality suppose $k=n$ and $\ell<n$ (otherwise replace $X$ by its complement). As $\ell$ is maximal, $n-\ell$ is even and $|X \cap[\ell, n]|=\frac{n-\ell}{2}$. For sufficiently small positive $\epsilon$, we take  $$ b_{i}=i \epsilon+ \begin{cases}0, & \text { if } i<\ell \\ \delta, & \text { if } \ell \leqslant i \leqslant n-1 \\ \gamma, & \text { if } i=n\end{cases} $$  Let $M=\sum_{i \in X} i$. So we require  $$ M \epsilon+\left(\frac{n-\ell}{2}-1\right) \delta+\gamma=1 $$  and  $$ \frac{n(n+1)}{2} \epsilon+(n-\ell) \delta+\gamma=2 $$  These give  $$ \gamma=2 \delta+\left(\frac{n(n+1)}{2}-2 M\right) \epsilon $$  and for sufficiently small positive $\epsilon$, solving for $\gamma$ and $\delta$ gives $0<\delta<\gamma$ (since $\epsilon=0$ gives $\delta=1 /\left(\frac{n-\ell}{2}+1\right)$ and $\left.\gamma=2 \delta\right)$, so the sequence is strictly increasing and has positive values.  Comment. This solution also shows that the claim gives a complete description of sets $X$ that are $\left(a_{i}\right)$-minimising for some $\left(a_{i}\right)$.  Another approach to proving the claim is as follows. We prove the existence of $\ell$ with the claimed property; the existence of $k$ follows by considering the complement of $X$.  Suppose, for a contradiction, that for all $1 \leqslant \ell \leqslant n$ we have $|X \cap[\ell, n]| \geqslant\left\lceil\frac{n-\ell+1}{2}\right\rceil$. If we ever have strict inequality, consider the set $Y=\{n, n-2, n-4, \ldots\}$. This set may be obtained from $X$ by possibly removing some elements and reducing the values of others. (To see this, consider the largest $k \in X \backslash Y$, if any; remove it, and replace it by the greatest $j \in X^{c}$ with $j<k$, if any. Such steps preserve the given inequality, and are possible until we reach the set $Y$.) So if we had strict inequality, and so $X \neq Y$, we have  $$ \sum_{i \in X} a_{i}>\sum_{i \in Y} a_{i}>1 $$  contradicting $X$ being $\left(a_{i}\right)$-minimising. Otherwise, we always have equality, meaning that $X=Y$. But now consider $Z=Y \cup\{n-1\} \backslash\{n\}$. Since $n \geqslant 3$, we have  $$ \sum_{i \in Y} a_{i}>\sum_{i \in Z} a_{i}>\sum_{i \in Y^{c}} a_{i}=2-\sum_{i \in Y} a_{i} $$  and so $Z$ contradicts $X$ being $\left(a_{i}\right)$-minimising.


Let $x_{1}, x_{2}, \ldots, x_{n}$ be different real numbers. Prove that  $$ \sum_{1 \leqslant i \leqslant n} \prod_{j \neq i} \frac{1-x_{i} x_{j}}{x_{i}-x_{j}}= \begin{cases}0, & \text { if } n \text { is even } \\ 1, & \text { if } n \text { is odd }\end{cases} $$  (Kazakhstan) Common remarks. Let $G\left(x_{1}, x_{2}, \ldots, x_{n}\right)$ be the function of the $n$ variables $x_{1}, x_{2}, \ldots, x_{n}$ on the LHS of the required identity.  Solution 1 (Lagrange interpolation). Since both sides of the identity are rational functions, it suffices to prove it when all $x_{i} \notin\{ \pm 1\}$. Define  $$ f(t)=\prod_{i=1}^{n}\left(1-x_{i} t\right) $$  and note that  $$ f\left(x_{i}\right)=\left(1-x_{i}^{2}\right) \prod_{j \neq i} 1-x_{i} x_{j} $$  Using the nodes $+1,-1, x_{1}, \ldots, x_{n}$, the Lagrange interpolation formula gives us the following expression for $f$ :  $$ \sum_{i=1}^{n} f\left(x_{i}\right) \frac{(x-1)(x+1)}{\left(x_{i}-1\right)\left(x_{i}+1\right)} \prod_{j \neq i} \frac{x-x_{j}}{x_{i}-x_{j}}+f(1) \frac{x+1}{1+1} \prod_{1 \leqslant i \leqslant n} \frac{x-x_{i}}{1-x_{i}}+f(-1) \frac{x-1}{-1-1} \prod_{1 \leqslant i \leqslant n} \frac{x-x_{i}}{1-x_{i}} $$  The coefficient of $t^{n+1}$ in $f(t)$ is 0 , since $f$ has degree $n$. The coefficient of $t^{n+1}$ in the above expression of $f$ is  $$ \begin{aligned} 0 & =\sum_{1 \leqslant i \leqslant n} \frac{f\left(x_{i}\right)}{\prod_{j \neq i}\left(x_{i}-x_{j}\right) \cdot\left(x_{i}-1\right)\left(x_{i}+1\right)}+\frac{f(1)}{\prod_{1 \leqslant j \leqslant n}\left(1-x_{j}\right) \cdot(1+1)}+\frac{f(-1)}{\prod_{1 \leqslant j \leqslant n}\left(-1-x_{j}\right) \cdot(-1-1)} \\ & =-G\left(x_{1}, \ldots, x_{n}\right)+\frac{1}{2}+\frac{(-1)^{n+1}}{2} \end{aligned} $$  Comment. The main difficulty is to think of including the two extra nodes $\pm 1$ and evaluating the coefficient $t^{n+1}$ in $f$ when $n+1$ is higher than the degree of $f$.  It is possible to solve the problem using Lagrange interpolation on the nodes $x_{1}, \ldots, x_{n}$, but the definition of the polynomial being interpolated should depend on the parity of $n$. For $n$ even, consider the polynomial  $$ P(x)=\prod_{i}\left(1-x x_{i}\right)-\prod_{i}\left(x-x_{i}\right) $$  Lagrange interpolation shows that $G$ is the coefficient of $x^{n-1}$ in the polynomial $P(x) /\left(1-x^{2}\right)$, i.e. 0 . For $n$ odd, consider the polynomial  $$ P(x)=\prod_{i}\left(1-x x_{i}\right)-x \prod_{i}\left(x-x_{i}\right) $$  Now $G$ is the coefficient of $x^{n-1}$ in $P(x) /\left(1-x^{2}\right)$, which is 1 .  Solution 2 (using symmetries). Observe that $G$ is symmetric in the variables $x_{1}, \ldots, x_{n}$. Define $V=\prod_{i<j}\left(x_{j}-x_{i}\right)$ and let $F=G \cdot V$, which is a polynomial in $x_{1}, \ldots, x_{n}$. Since $V$ is alternating, $F$ is also alternating (meaning that, if we exchange any two variables, then $F$ changes sign). Every alternating polynomial in $n$ variables $x_{1}, \ldots, x_{n}$ vanishes when any two variables $x_{i}, x_{j}(i \neq j)$ are equal, and is therefore divisible by $x_{i}-x_{j}$ for each pair $i \neq j$. Since these linear factors are pairwise coprime, $V$ divides $F$ exactly as a polynomial. Thus $G$ is in fact a symmetric polynomial in $x_{1}, \ldots, x_{n}$.  Now observe that if all $x_{i}$ are nonzero and we set $y_{i}=1 / x_{i}$ for $i=1, \ldots, n$, then we have  $$ \frac{1-y_{i} y_{j}}{y_{i}-y_{j}}=\frac{1-x_{i} x_{j}}{x_{i}-x_{j}} $$  so that  $$ G\left(\frac{1}{x_{1}}, \ldots, \frac{1}{x_{n}}\right)=G\left(x_{1}, \ldots, x_{n}\right) . $$  By continuity this is an identity of rational functions. Since $G$ is a polynomial, it implies that $G$ is constant. (If $G$ were not constant, we could choose a point $\left(c_{1}, \ldots, c_{n}\right)$ with all $c_{i} \neq 0$, such that $G\left(c_{1}, \ldots, c_{n}\right) \neq G(0, \ldots, 0)$; then $g(x):=G\left(c_{1} x, \ldots, c_{n} x\right)$ would be a nonconstant polynomial in the variable $x$, so $|g(x)| \rightarrow \infty$ as $x \rightarrow \infty$, hence $\left|G\left(\frac{y}{c_{1}}, \ldots, \frac{y}{c_{n}}\right)\right| \rightarrow \infty$ as $y \rightarrow 0$, which is impossible since $G$ is a polynomial.)  We may identify the constant by substituting $x_{i}=\zeta^{i}$, where $\zeta$ is a primitive $n^{\text {th }}$ root of unity in $\mathbb{C}$. In the $i^{\text {th }}$ term in the sum in the original expression we have a factor $1-\zeta^{i} \zeta^{n-i}=0$, unless $i=n$ or $2 i=n$. In the case where $n$ is odd, the only exceptional term is $i=n$, which gives the value $\prod_{j \neq n} \frac{1-\zeta^{j}}{1-\zeta^{j}}=1$. When $n$ is even, we also have the term $\prod_{j \neq \frac{n}{2}} \frac{1+\zeta^{j}}{-1-\zeta^{j}}=(-1)^{n-1}=-1$, so the sum is 0 .  Comment. If we write out an explicit expression for $F$,  $$ F=\sum_{1 \leqslant i \leqslant n}(-1)^{n-i} \prod_{\substack{j<k \\ j, k \neq i}}\left(x_{k}-x_{j}\right) \prod_{j \neq i}\left(1-x_{i} x_{j}\right) $$  then to prove directly that $F$ vanishes when $x_{i}=x_{j}$ for some $i \neq j$, but no other pair of variables coincide, we have to check carefully that the two nonzero terms in this sum cancel.  A different and slightly less convenient way to identify the constant is to substitute $x_{i}=1+\epsilon \zeta^{i}$, and throw away terms that are $O(\epsilon)$ as $\epsilon \rightarrow 0$.  Solution 3 (breaking symmetry). Consider $G$ as a rational function in $x_{n}$ with coefficients that are rational functions in the other variables. We can write  $$ G\left(x_{1}, \ldots, x_{n}\right)=\frac{P\left(x_{n}\right)}{\prod_{j \neq n}\left(x_{n}-x_{j}\right)} $$  where $P\left(x_{n}\right)$ is a polynomial in $x_{n}$ whose coefficients are rational functions in the other variables. We then have  $$ P\left(x_{n}\right)=\left(\prod_{j \neq n}\left(1-x_{n} x_{j}\right)\right)+\sum_{1 \leqslant i \leqslant n-1}\left(x_{i} x_{n}-1\right)\left(\prod_{j \neq i, n}\left(x_{n}-x_{j}\right)\right)\left(\prod_{j \neq i, n} \frac{1-x_{i} x_{j}}{x_{i}-x_{j}}\right) . $$  For any $k \neq n$, substituting $x_{n}=x_{k}$ (which is valid when manipulating the numerator $P\left(x_{n}\right)$ on its own), we have (noting that $x_{n}-x_{j}$ vanishes when $j=k$ )  $$ \begin{aligned} P\left(x_{k}\right) & =\left(\prod_{j \neq n}\left(1-x_{k} x_{j}\right)\right)+\sum_{1 \leqslant i \leqslant n-1}\left(x_{i} x_{k}-1\right)\left(\prod_{j \neq i, n}\left(x_{k}-x_{j}\right)\right)\left(\prod_{j \neq i, n} \frac{1-x_{i} x_{j}}{x_{i}-x_{j}}\right) \\ & =\left(\prod_{j \neq n}\left(1-x_{k} x_{j}\right)\right)+\left(x_{k}^{2}-1\right)\left(\prod_{j \neq k, n}\left(x_{k}-x_{j}\right)\right)\left(\prod_{j \neq k, n} \frac{1-x_{k} x_{j}}{x_{k}-x_{j}}\right) \\ & =\left(\prod_{j \neq n}\left(1-x_{k} x_{j}\right)\right)+\left(x_{k}^{2}-1\right)\left(\prod_{j \neq k, n}\left(1-x_{k} x_{j}\right)\right) \\ & =0 . \end{aligned} $$  Note that $P$ is a polynomial in $x_{n}$ of degree $n-1$. For any choice of distinct real numbers $x_{1}, \ldots, x_{n-1}, P$ has those real numbers as its roots, and the denominator has the same degree and the same roots. This shows that $G$ is constant in $x_{n}$, for any fixed choice of distinct $x_{1}, \ldots, x_{n-1}$. Now, $G$ is symmetric in all $n$ variables, so it must be also be constant in each of the other variables. $G$ is therefore a constant that depends only on $n$. The constant may be identified as in the previous solution.  Comment. There is also a solution in which we recognise the expression for $F$ in the comment after Solution 2 as the final column expansion of a certain matrix obtained by modifying the final column of the Vandermonde matrix. The task is then to show that the matrix can be modified by column operations either to make the final column identically zero (in the case where $n$ even) or to recover the Vandermonde matrix (in the case where $n$ odd). The polynomial $P /\left(1-x^{2}\right)$ is helpful for this task, where $P$ is the parity-dependent polynomial defined in the comment after Solution 1.


A polynomial $P(x, y, z)$ in three variables with real coefficients satisfies the identities  $$ P(x, y, z)=P(x, y, x y-z)=P(x, z x-y, z)=P(y z-x, y, z) . $$  Prove that there exists a polynomial $F(t)$ in one variable such that  $$ P(x, y, z)=F\left(x^{2}+y^{2}+z^{2}-x y z\right) . $$  (Russia) Common remarks. The polynomial $x^{2}+y^{2}+z^{2}-x y z$ satisfies the condition (*), so every polynomial of the form $F\left(x^{2}+y^{2}+z^{2}-x y z\right)$ does satisfy (*). We will use without comment the fact that two polynomials have the same coefficients if and only if they are equal as functions.

Solution: In the first two steps, we deal with any polynomial $P(x, y, z)$ satisfying $P(x, y, z)=$ $P(x, y, x y-z)$. Call such a polynomial weakly symmetric, and call a polynomial satisfying the full conditions in the problem symmetric. Step 1. We start with the description of weakly symmetric polynomials. We claim that they are exactly the polynomials in $x, y$, and $z(x y-z)$. Clearly, all such polynomials are weakly symmetric. For the converse statement, consider $P_{1}(x, y, z):=P\left(x, y, z+\frac{1}{2} x y\right)$, which satisfies $P_{1}(x, y, z)=P_{1}(x, y,-z)$ and is therefore a polynomial in $x, y$, and $z^{2}$. This means that $P$ is a polynomial in $x, y$, and $\left(z-\frac{1}{2} x y\right)^{2}=-z(x y-z)+\frac{1}{4} x^{2} y^{2}$, and therefore a polynomial in $x, y$, and $z(x y-z)$. Step 2. Suppose that $P$ is weakly symmetric. Consider the monomials in $P(x, y, z)$ of highest total degree. Our aim is to show that in each such monomial $\mu x^{a} y^{b} z^{c}$ we have $a, b \geqslant c$. Consider the expansion  $$ P(x, y, z)=\sum_{i, j, k} \mu_{i j k} x^{i} y^{j}(z(x y-z))^{k} $$  The maximal total degree of a summand in (1.1) is $m=\max _{i, j, k: \mu_{i j k} \neq 0}(i+j+3 k)$. Now, for any $i, j, k$ satisfying $i+j+3 k=m$ the summand $\mu_{i, j, k} x^{i} y^{j}(z(x y-z))^{k}$ has leading term of the form $\mu x^{i+k} y^{j+k} z^{k}$. No other nonzero summand in (1.1) may have a term of this form in its expansion, hence this term does not cancel in the whole sum. Therefore, $\operatorname{deg} P=m$, and the leading component of $P$ is exactly  $$ \sum_{i+j+3 k=m} \mu_{i, j, k} x^{i+k} y^{j+k} z^{k} $$  and each summand in this sum satisfies the condition claimed above. Step 3. We now prove the problem statement by induction on $m=\operatorname{deg} P$. For $m=0$ the claim is trivial. Consider now a symmetric polynomial $P$ with $\operatorname{deg} P>0$. By Step 2, each of its monomials $\mu x^{a} y^{b} z^{c}$ of the highest total degree satisfies $a, b \geqslant c$. Applying other weak symmetries, we obtain $a, c \geqslant b$ and $b, c \geqslant a$; therefore, $P$ has a unique leading monomial of the form $\mu(x y z)^{c}$. The polynomial $P_{0}(x, y, z)=P(x, y, z)-\mu\left(x y z-x^{2}-y^{2}-z^{2}\right)^{c}$ has smaller total degree. Since $P_{0}$ is symmetric, it is representable as a polynomial function of $x y z-x^{2}-y^{2}-z^{2}$. Then $P$ is also of this form, completing the inductive step.  Comment. We could alternatively carry out Step 1 by an induction on $n=\operatorname{deg}_{z} P$, in a manner similar to Step 3. If $n=0$, the statement holds. Assume that $n>0$ and check the leading component of $P$ with respect to $z$ :  $$ P(x, y, z)=Q_{n}(x, y) z^{n}+R(x, y, z) $$  where $\operatorname{deg}_{z} R<n$. After the change $z \mapsto x y-z$, the leading component becomes $Q_{n}(x, y)(-z)^{n}$; on the other hand, it should remain the same. Hence $n$ is even. Now consider the polynomial  $$ P_{0}(x, y, z)=P(x, y, z)-Q_{n}(x, y) \cdot(z(z-x y))^{n / 2} $$  It is also weakly symmetric, and $\operatorname{deg}_{z} P_{0}<n$. By the inductive hypothesis, it has the form $P_{0}(x, y, z)=$ $S(x, y, z(z-x y))$. Hence the polynomial  $$ P(x, y, z)=S(x, y, z(x y-z))+Q_{n}(x, y)(z(z-x y))^{n / 2} $$  also has this form. This completes the inductive step.


Solution: We will rely on the well-known identity  $$ \cos ^{2} u+\cos ^{2} v+\cos ^{2} w-2 \cos u \cos v \cos w-1=0 \quad \text { whenever } u+v+w=0 $$  Claim 1. The polynomial $P(x, y, z)$ is constant on the surface  $$ \mathfrak{S}=\{(2 \cos u, 2 \cos v, 2 \cos w): u+v+w=0\} $$  Proof. Notice that for $x=2 \cos u, y=2 \cos v, z=2 \cos w$, the Vieta jumps $x \mapsto y z-x$, $y \mapsto z x-y, z \mapsto x y-z$ in (*) replace $(u, v, w)$ by $(v-w,-v, w),(u, w-u,-w)$ and $(-u, v, u-v)$, respectively. For example, for the first type of jump we have  $$ y z-x=4 \cos v \cos w-2 \cos u=2 \cos (v+w)+2 \cos (v-w)-2 \cos u=2 \cos (v-w) . $$  Define $G(u, v, w)=P(2 \cos u, 2 \cos v, 2 \cos w)$. For $u+v+w=0$, the jumps give  $$ \begin{aligned} G(u, v, w) & =G(v-w,-v, w)=G(w-v,-v,(v-w)-(-v))=G(-u-2 v,-v, 2 v-w) \\ & =G(u+2 v, v, w-2 v) \end{aligned} $$  By induction,  $$ G(u, v, w)=G(u+2 k v, v, w-2 k v) \quad(k \in \mathbb{Z}) $$  Similarly,  $$ G(u, v, w)=G(u, v-2 \ell u, w+2 \ell u) \quad(\ell \in \mathbb{Z}) $$  And, of course, we have  $$ G(u, v, w)=G(u+2 p \pi, v+2 q \pi, w-2(p+q) \pi) \quad(p, q \in \mathbb{Z}) $$  Take two nonzero real numbers $u, v$ such that $u, v$ and $\pi$ are linearly independent over $\mathbb{Q}$. By combining (2.2-2.4), we can see that $G$ is constant on a dense subset of the plane $u+v+w=0$. By continuity, $G$ is constant on the entire plane and therefore $P$ is constant on $\mathfrak{S}$. Claim 2. The polynomial $T(x, y, z)=x^{2}+y^{2}+z^{2}-x y z-4$ divides $P(x, y, z)-P(2,2,2)$. Proof. By dividing $P$ by $T$ with remainders, there exist some polynomials $R(x, y, z), A(y, z)$ and $B(y, z)$ such that  $$ P(x, y, z)-P(2,2,2)=T(x, y, z) \cdot R(x, y, z)+A(y, z) x+B(y, z) $$  On the surface $\mathfrak{S}$ the LHS of (2.5) is zero by Claim 1 (since $(2,2,2) \in \mathfrak{S}$ ) and $T=0$ by (2.1). Hence, $A(y, z) x+B(y, z)$ vanishes on $\mathfrak{S}$.  Notice that for every $y=2 \cos v$ and $z=2 \cos w$ with $\frac{\pi}{3}<v, w<\frac{2 \pi}{3}$, there are two distinct values of $x$ such that $(x, y, z) \in \mathfrak{S}$, namely $x_{1}=2 \cos (v+w)$ (which is negative), and $x_{2}=2 \cos (v-w)$ (which is positive). This can happen only if $A(y, z)=B(y, z)=0$. Hence, $A(y, z)=B(y, z)=0$ for $|y|<1,|z|<1$. The polynomials $A$ and $B$ vanish on an open set, so $A$ and $B$ are both the zero polynomial.  The quotient $(P(x, y, z)-P(2,2,2)) / T(x, y, z)$ is a polynomial of lower degree than $P$ and it also satisfies (*). The problem statement can now be proven by induction on the degree of $P$.  Comment. In the proof of (2.2) and (2.3) we used two consecutive Vieta jumps; in fact from (*) we used only $P(x, y, x y-z)=P(x, z x-y, z)=P(y z-x, y, z)$.  Solution 3 (using algebraic geometry, just for interest). Let $Q=x^{2}+y^{2}+z^{2}-x y z$ and let $t \in \mathbb{C}$. Checking where $Q-t, \frac{\partial Q}{\partial x}, \frac{\partial Q}{\partial y}$ and $\frac{\partial Q}{\partial z}$ vanish simultaneously, we find that the surface $Q=t$ is smooth except for the cases $t=0$, when the only singular point is $(0,0,0)$, and $t=4$, when the four points $( \pm 2, \pm 2, \pm 2)$ that satisfy $x y z=8$ are the only singular points. The singular points are the fixed points of the group $\Gamma$ of polynomial automorphisms of $\mathbb{C}^{3}$ generated by the three Vieta involutions  $$ \iota_{1}:(x, y, z) \mapsto(x, y, x y-z), \quad \iota_{2}:(x, y, z) \mapsto(x, x z-y, z), \quad \iota_{3}:(x, y, z) \mapsto(y z-x, y, z) $$  $\Gamma$ acts on each surface $\mathcal{V}_{t}: Q-t=0$. If $Q-t$ were reducible then the surface $Q=t$ would contain a curve of singular points. Therefore $Q-t$ is irreducible in $\mathbb{C}[x, y, z]$. (One can also prove algebraically that $Q-t$ is irreducible, for example by checking that its discriminant as a quadratic polynomial in $x$ is not a square in $\mathbb{C}[y, z]$, and likewise for the other two variables.) In the following solution we will only use the algebraic surface $\mathcal{V}_{0}$.  Let $U$ be the $\Gamma$-orbit of $(3,3,3)$. Consider $\iota_{3} \circ \iota_{2}$, which leaves $z$ invariant. For each fixed value of $z, \iota_{3} \circ \iota_{2}$ acts linearly on $(x, y)$ by the matrix  $$ M_{z}:=\left(\begin{array}{cc} z^{2}-1 & -z \\ z & -1 \end{array}\right) $$  The reverse composition $\iota_{2} \circ \iota_{3}$ acts by $M_{z}^{-1}=M_{z}^{\text {adj }}$. Note det $M_{z}=1$ and $\operatorname{tr} M_{z}=z^{2}-2$. When $z$ does not lie in the real interval $[-2,2]$, the eigenvalues of $M_{z}$ do not have absolute value 1 , so every orbit of the group generated by $M_{z}$ on $\mathbb{C}^{2} \backslash\{(0,0)\}$ is unbounded. For example, fixing $z=3$ we find $\left(3 F_{2 k+1}, 3 F_{2 k-1}, 3\right) \in U$ for every $k \in \mathbb{Z}$, where $\left(F_{n}\right)_{n \in \mathbb{Z}}$ is the Fibonacci sequence with $F_{0}=0, F_{1}=1$.  Now we may start at any point $\left(3 F_{2 k+1}, 3 F_{2 k-1}, 3\right)$ and iteratively apply $\iota_{1} \circ \iota_{2}$ to generate another infinite sequence of distinct points of $U$, Zariski dense in the hyperbola cut out of $\mathcal{V}_{0}$ by the plane $x-3 F_{2 k+1}=0$. (The plane $x=a$ cuts out an irreducible conic when $a \notin\{-2,0,2\}$.) Thus the Zariski closure $\bar{U}$ of $U$ contains infinitely many distinct algebraic curves in $\mathcal{V}_{0}$. Since $\mathcal{V}_{0}$ is an irreducible surface this implies that $\bar{U}=\mathcal{V}_{0}$.  For any polynomial $P$ satisfying (*), we have $P-P(3,3,3)=0$ at each point of $U$. Since $\bar{U}=\mathcal{V}_{0}, P-P(3,3,3)$ vanishes on $\mathcal{V}_{0}$. Then Hilbert's Nullstellensatz and the irreducibility of $Q$ imply that $P-P(3,3,3)$ is divisible by $Q$. Now $(P-P(3,3,3)) / Q$ is a polynomial also satisfying (*), so we may complete the proof by an induction on the total degree, as in the other solutions.  Comment. We remark that Solution 2 used a trigonometric parametrisation of a real component of $\mathcal{V}_{4} ;$ in contrast $\mathcal{V}_{0}$ is birationally equivalent to the projective space $\mathbb{P}^{2}$ under the maps  $$ (x, y, z) \rightarrow(x: y: z), \quad(a: b: c) \rightarrow\left(\frac{a^{2}+b^{2}+c^{2}}{b c}, \frac{a^{2}+b^{2}+c^{2}}{a c}, \frac{a^{2}+b^{2}+c^{2}}{a b}\right) . $$  The set $U$ in Solution 3 is contained in $\mathbb{Z}^{3}$ so it is nowhere dense in $\mathcal{V}_{0}$ in the classical topology. Comment (background to the problem). A triple $(a, b, c) \in \mathbb{Z}^{3}$ is called a Markov triple if $a^{2}+b^{2}+c^{2}=3 a b c$, and an integer that occurs as a coordinate of some Markov triple is called a Markov number. (The spelling Markoff is also frequent.) Markov triples arose in A. Markov's work in the 1870s on the reduction theory of indefinite binary quadratic forms. For every Markov triple, $(3 a, 3 b, 3 c)$ lies on $Q=0$. It is well known that all nonzero Markov triples can be generated from $(1,1,1)$ by sequences of Vieta involutions, which are the substitutions described in equation (*) in the problem statement. There has been recent work by number theorists about the properties of Markov numbers (see for example Jean Bourgain, Alex Gamburd and Peter Sarnak, Markoff triples and strong approximation, Comptes Rendus Math. 345, no. 2, 131-135 (2016), arXiv:1505.06411). Each Markov number occurs in infinitely many triples, but a famous old open problem is the unicity conjecture, which asserts that each Markov number occurs in only one Markov triple (up to permutations and sign changes) as the largest coordinate in absolute value in that triple. It is a standard fact in the modern literature on Markov numbers that the Markov triples are Zariski dense in the Markov surface. Proving this is the main work of Solution 3. Algebraic geometry is definitely off-syllabus for the IMO, and one still has to work a bit to prove the Zariski density. On the other hand the approaches of Solutions 1 and 2 are elementary and only use tools expected to be known by IMO contestants. Therefore we do not think that the existence of a solution using algebraic geometry necessarily makes this problem unsuitable for the IMO.


Let $\mathbb{Z}$ be the set of integers. We consider functions $f: \mathbb{Z} \rightarrow \mathbb{Z}$ satisfying  $$ f(f(x+y)+y)=f(f(x)+y) $$  for all integers $x$ and $y$. For such a function, we say that an integer $v$ is $f$-rare if the set  $$ X_{v}=\{x \in \mathbb{Z}: f(x)=v\} $$  is finite and nonempty. (a) Prove that there exists such a function $f$ for which there is an $f$-rare integer. (b) Prove that no such function $f$ can have more than one $f$-rare integer. (Netherlands)

Solution: a) Let $f$ be the function where $f(0)=0$ and $f(x)$ is the largest power of 2 dividing $2 x$ for $x \neq 0$. The integer 0 is evidently $f$-rare, so it remains to verify the functional equation.  Since $f(2 x)=2 f(x)$ for all $x$, it suffices to verify the functional equation when at least one of $x$ and $y$ is odd (the case $x=y=0$ being trivial). If $y$ is odd, then we have  $$ f(f(x+y)+y)=2=f(f(x)+y) $$  since all the values attained by $f$ are even. If, on the other hand, $x$ is odd and $y$ is even, then we already have  $$ f(x+y)=2=f(x) $$  from which the functional equation follows immediately. b) An easy inductive argument (substituting $x+k y$ for $x$ ) shows that  $$ f(f(x+k y)+y)=f(f(x)+y) $$  for all integers $x, y$ and $k$. If $v$ is an $f$-rare integer and $a$ is the least element of $X_{v}$, then by substituting $y=a-f(x)$ in the above, we see that  $$ f(x+k \cdot(a-f(x)))-f(x)+a \in X_{v} $$  for all integers $x$ and $k$, so that in particular  $$ f(x+k \cdot(a-f(x))) \geqslant f(x) $$  for all integers $x$ and $k$, by assumption on $a$. This says that on the (possibly degenerate) arithmetic progression through $x$ with common difference $a-f(x)$, the function $f$ attains its minimal value at $x$.  Repeating the same argument with $a$ replaced by the greatest element $b$ of $X_{v}$ shows that  $$ f(x+k \cdot(b-f(x)) \leqslant f(x) $$  for all integers $x$ and $k$. Combined with the above inequality, we therefore have  $$ f(x+k \cdot(a-f(x)) \cdot(b-f(x)))=f(x) $$  for all integers $x$ and $k$. Thus if $f(x) \neq a, b$, then the set $X_{f(x)}$ contains a nondegenerate arithmetic progression, so is infinite. So the only possible $f$-rare integers are $a$ and $b$.  In particular, the $f$-rare integer $v$ we started with must be one of $a$ or $b$, so that $f(v)=$ $f(a)=f(b)=v$. This means that there cannot be any other $f$-rare integers $v^{\prime}$, as they would on the one hand have to be either $a$ or $b$, and on the other would have to satisfy $f\left(v^{\prime}\right)=v^{\prime}$. Thus $v$ is the unique $f$-rare integer.  Comment 1. If $f$ is a solution to the functional equation, then so too is any conjugate of $f$ by a translation, i.e. any function $x \mapsto f(x+n)-n$ for an integer $n$. Thus in proving part (b), one is free to consider only functions $f$ for which 0 is $f$-rare, as in the following solution.  Solution 2, part (b) only. Suppose $v$ is $f$-rare, and let $a$ and $b$ be the least and greatest elements of $X_{v}$, respectively. Substituting $x=v$ and $y=a-v$ into the equation shows that  $$ f(v)-v+a \in X_{v} $$  and in particular $f(v) \geqslant v$. Repeating the same argument with $x=v$ and $y=b-v$ shows that $f(v) \leqslant v$, and hence $f(v)=v$.  Suppose now that $v^{\prime}$ is a second $f$-rare integer. We may assume that $v=0$ (see Comment 1 ). We've seen that $f\left(v^{\prime}\right)=v^{\prime}$; we claim that in fact $f\left(k v^{\prime}\right)=v^{\prime}$ for all positive integers $k$. This gives a contradiction unless $v^{\prime}=v=0$.  This claim is proved by induction on $k$. Supposing it to be true for $k$, we substitute $y=k v^{\prime}$ and $x=0$ into the functional equation to yield  $$ f\left((k+1) v^{\prime}\right)=f\left(f(0)+k v^{\prime}\right)=f\left(k v^{\prime}\right)=v^{\prime} $$  using that $f(0)=0$. This completes the induction, and hence the proof. Comment 2. There are many functions $f$ satisfying the functional equation for which there is an $f$-rare integer. For instance, one may generalise the construction in part (a) of Solution 1 by taking a sequence $1=a_{0}, a_{1}, a_{2}, \ldots$ of positive integers with each $a_{i}$ a proper divisor of $a_{i+1}$ and choosing arbitrary functions $f_{i}:\left(\mathbb{Z} / a_{i} \mathbb{Z}\right) \backslash\{0\} \rightarrow a_{i} \mathbb{Z} \backslash\{0\}$ from the nonzero residue classes modulo $a_{i}$ to the nonzero multiples of $a_{i}$. One then defines a function $f: \mathbb{Z} \rightarrow \mathbb{Z}$ by  $$ f(x):= \begin{cases}f_{i+1}\left(x \bmod a_{i+1}\right), & \text { if } a_{i} \mid x \text { but } a_{i+1} \nmid x \\ 0, & \text { if } x=0\end{cases} $$  If one writes $v(x)$ for the largest $i$ such that $a_{i} \mid x$ (with $v(0)=\infty$ ), then it is easy to verify the functional equation for $f$ separately in the two cases $v(y)>v(x)$ and $v(x) \geqslant v(y)$. Hence this $f$ satisfies the functional equation and 0 is an $f$-rare integer.  Comment 3. In fact, if $v$ is an $f$-rare integer for an $f$ satisfying the functional equation, then its fibre $X_{v}=\{v\}$ must be a singleton. We may assume without loss of generality that $v=0$. We've already seen in Solution 1 that 0 is either the greatest or least element of $X_{0}$; replacing $f$ with the function $x \mapsto-f(-x)$ if necessary, we may assume that 0 is the least element of $X_{0}$. We write $b$ for the largest element of $X_{0}$, supposing for contradiction that $b>0$, and write $N=(2 b)$ !.  It now follows from (*) that we have  $$ f(f(N b)+b)=f(f(0)+b)=f(b)=0 $$  from which we see that $f(N b)+b \in X_{0} \subseteq[0, b]$. It follows that $f(N b) \in[-b, 0)$, since by construction $N b \notin X_{v}$. Now it follows that $(f(N b)-0) \cdot(f(N b)-b)$ is a divisor of $N$, so from ( $\dagger$ ) we see that $f(N b)=f(0)=0$. This yields the desired contradiction.


The infinite sequence $a_{0}, a_{1}, a_{2}, \ldots$ of (not necessarily different) integers has the following properties: $0 \leqslant a_{i} \leqslant i$ for all integers $i \geqslant 0$, and  $$ \binom{k}{a_{0}}+\binom{k}{a_{1}}+\cdots+\binom{k}{a_{k}}=2^{k} $$  for all integers $k \geqslant 0$. Prove that all integers $N \geqslant 0$ occur in the sequence (that is, for all $N \geqslant 0$, there exists $i \geqslant 0$ with $\left.a_{i}=N\right)$. (Netherlands)

Solution: We prove by induction on $k$ that every initial segment of the sequence, $a_{0}, a_{1}, \ldots, a_{k}$, consists of the following elements (counted with multiplicity, and not necessarily in order), for some $\ell \geqslant 0$ with $2 \ell \leqslant k+1$ :  $$ 0,1, \ldots, \ell-1, \quad 0,1, \ldots, k-\ell $$  For $k=0$ we have $a_{0}=0$, which is of this form. Now suppose that for $k=m$ the elements $a_{0}, a_{1}, \ldots, a_{m}$ are $0,0,1,1,2,2, \ldots, \ell-1, \ell-1, \ell, \ell+1, \ldots, m-\ell-1, m-\ell$ for some $\ell$ with $0 \leqslant 2 \ell \leqslant m+1$. It is given that  $$ \binom{m+1}{a_{0}}+\binom{m+1}{a_{1}}+\cdots+\binom{m+1}{a_{m}}+\binom{m+1}{a_{m+1}}=2^{m+1} $$  which becomes  $$ \begin{aligned} \left(\binom{m+1}{0}+\binom{m+1}{1}\right. & \left.+\cdots+\binom{m+1}{\ell-1}\right) \\ & +\left(\binom{m+1}{0}+\binom{m+1}{1}+\cdots+\binom{m+1}{m-\ell}\right)+\binom{m+1}{a_{m+1}}=2^{m+1} \end{aligned} $$  or, using $\binom{m+1}{i}=\binom{m+1}{m+1-i}$, that  $$ \begin{aligned} \left(\binom{m+1}{0}+\binom{m+1}{1}\right. & \left.+\cdots+\binom{m+1}{\ell-1}\right) \\ & +\left(\binom{m+1}{m+1}+\binom{m+1}{m}+\cdots+\binom{m+1}{\ell+1}\right)+\binom{m+1}{a_{m+1}}=2^{m+1} \end{aligned} $$  On the other hand, it is well known that  $$ \binom{m+1}{0}+\binom{m+1}{1}+\cdots+\binom{m+1}{m+1}=2^{m+1} $$  and so, by subtracting, we get  $$ \binom{m+1}{a_{m+1}}=\binom{m+1}{\ell} $$  From this, using the fact that the binomial coefficients $\binom{m+1}{i}$ are increasing for $i \leqslant \frac{m+1}{2}$ and decreasing for $i \geqslant \frac{m+1}{2}$, we conclude that either $a_{m+1}=\ell$ or $a_{m+1}=m+1-\ell$. In either case, $a_{0}, a_{1}, \ldots, a_{m+1}$ is again of the claimed form, which concludes the induction.  As a result of this description, any integer $N \geqslant 0$ appears as a term of the sequence $a_{i}$ for some $0 \leqslant i \leqslant 2 N$.


Let $n$ be a positive integer. Harry has $n$ coins lined up on his desk, each showing  heads or tails. He repeatedly does the following operation: if there are $k$ coins showing heads and $k>0$, then he flips the $k^{\text {th }}$ coin over; otherwise he stops the process. (For example, the process starting with THT would be THT $\rightarrow H H T \rightarrow H T T \rightarrow T T T$, which takes three steps.)  Letting $C$ denote the initial configuration (a sequence of $n H$ 's and $T$ 's), write $\ell(C)$ for the number of steps needed before all coins show $T$. Show that this number $\ell(C)$ is finite, and determine its average value over all $2^{n}$ possible initial configurations $C$.  Answer: The average is $\frac{1}{4} n(n+1)$. Common remarks. Throughout all these solutions, we let $E(n)$ denote the desired average value.

Solution: We represent the problem using a directed graph $G_{n}$ whose vertices are the length- $n$ strings of $H$ 's and $T$ 's. The graph features an edge from each string to its successor (except for $T T \cdots T T$, which has no successor). We will also write $\bar{H}=T$ and $\bar{T}=H$.  The graph $G_{0}$ consists of a single vertex: the empty string. The main claim is that $G_{n}$ can be described explicitly in terms of $G_{n-1}$ :  - We take two copies, $X$ and $Y$, of $G_{n-1}$. - In $X$, we take each string of $n-1$ coins and just append a $T$ to it. In symbols, we replace $s_{1} \cdots s_{n-1}$ with $s_{1} \cdots s_{n-1} T$. - In $Y$, we take each string of $n-1$ coins, flip every coin, reverse the order, and append an $H$ to it. In symbols, we replace $s_{1} \cdots s_{n-1}$ with $\bar{s}_{n-1} \bar{s}_{n-2} \cdots \bar{s}_{1} H$. - Finally, we add one new edge from $Y$ to $X$, namely $H H \cdots H H H \rightarrow H H \cdots H H T$.  We depict $G_{4}$ below, in a way which indicates this recursive construction: ![](https://cdn.mathpix.com/cropped/2024_11_18_9ee8c2ac2c2f5002ff14g-034.jpg?height=515&width=1135&top_left_y=1850&top_left_x=466)  We prove the claim inductively. Firstly, $X$ is correct as a subgraph of $G_{n}$, as the operation on coins is unchanged by an extra $T$ at the end: if $s_{1} \cdots s_{n-1}$ is sent to $t_{1} \cdots t_{n-1}$, then $s_{1} \cdots s_{n-1} T$ is sent to $t_{1} \cdots t_{n-1} T$.  Next, $Y$ is also correct as a subgraph of $G_{n}$, as if $s_{1} \cdots s_{n-1}$ has $k$ occurrences of $H$, then $\bar{s}_{n-1} \cdots \bar{s}_{1} H$ has $(n-1-k)+1=n-k$ occurrences of $H$, and thus (provided that $k>0$ ), if $s_{1} \cdots s_{n-1}$ is sent to $t_{1} \cdots t_{n-1}$, then $\bar{s}_{n-1} \cdots \bar{s}_{1} H$ is sent to $\bar{t}_{n-1} \cdots \bar{t}_{1} H$.  Finally, the one edge from $Y$ to $X$ is correct, as the operation does send $H H \cdots H H H$ to HH $\cdots$ HHT.  To finish, note that the sequences in $X$ take an average of $E(n-1)$ steps to terminate, whereas the sequences in $Y$ take an average of $E(n-1)$ steps to reach $H H \cdots H$ and then an additional $n$ steps to terminate. Therefore, we have  $$ E(n)=\frac{1}{2}(E(n-1)+(E(n-1)+n))=E(n-1)+\frac{n}{2} $$  We have $E(0)=0$ from our description of $G_{0}$. Thus, by induction, we have $E(n)=\frac{1}{2}(1+\cdots+$ $n)=\frac{1}{4} n(n+1)$, which in particular is finite.


Solution: We consider what happens with configurations depending on the coins they start and end with.  - If a configuration starts with $H$, the last $n-1$ coins follow the given rules, as if they were all the coins, until they are all $T$, then the first coin is turned over. - If a configuration ends with $T$, the last coin will never be turned over, and the first $n-1$ coins follow the given rules, as if they were all the coins. - If a configuration starts with $T$ and ends with $H$, the middle $n-2$ coins follow the given rules, as if they were all the coins, until they are all $T$. After that, there are $2 n-1$ more steps: first coins $1,2, \ldots, n-1$ are turned over in that order, then coins $n, n-1, \ldots, 1$ are turned over in that order.  As this covers all configurations, and the number of steps is clearly finite for 0 or 1 coins, it follows by induction on $n$ that the number of steps is always finite.  We define $E_{A B}(n)$, where $A$ and $B$ are each one of $H, T$ or $*$, to be the average number of steps over configurations of length $n$ restricted to those that start with $A$, if $A$ is not $*$, and that end with $B$, if $B$ is not * (so * represents "either $H$ or $T$ "). The above observations tell us that, for $n \geqslant 2$ :  - $E_{H *}(n)=E(n-1)+1$. - $E_{* T}(n)=E(n-1)$. - $E_{H T}(n)=E(n-2)+1$ (by using both the observations for $H *$ and for $\left.* T\right)$. - $E_{T H}(n)=E(n-2)+2 n-1$.  Now $E_{H *}(n)=\frac{1}{2}\left(E_{H H}(n)+E_{H T}(n)\right)$, so $E_{H H}(n)=2 E(n-1)-E(n-2)+1$. Similarly, $E_{T T}(n)=2 E(n-1)-E(n-2)-1$. So  $$ E(n)=\frac{1}{4}\left(E_{H T}(n)+E_{H H}(n)+E_{T T}(n)+E_{T H}(n)\right)=E(n-1)+\frac{n}{2} $$  We have $E(0)=0$ and $E(1)=\frac{1}{2}$, so by induction on $n$ we have $E(n)=\frac{1}{4} n(n+1)$.


Solution: Let $H_{i}$ be the number of heads in positions 1 to $i$ inclusive (so $H_{n}$ is the total number of heads), and let $I_{i}$ be 1 if the $i^{\text {th }}$ coin is a head, 0 otherwise. Consider the function  $$ t(i)=I_{i}+2\left(\min \left\{i, H_{n}\right\}-H_{i}\right) $$  We claim that $t(i)$ is the total number of times coin $i$ is turned over (which implies that the process terminates). Certainly $t(i)=0$ when all coins are tails, and $t(i)$ is always a nonnegative integer, so it suffices to show that when the $k^{\text {th }}$ coin is turned over (where $k=H_{n}$ ), $t(k)$ goes down by 1 and all the other $t(i)$ are unchanged. We show this by splitting into cases:  - If $i<k, I_{i}$ and $H_{i}$ are unchanged, and $\min \left\{i, H_{n}\right\}=i$ both before and after the coin flip, so $t(i)$ is unchanged. - If $i>k, \min \left\{i, H_{n}\right\}=H_{n}$ both before and after the coin flip, and both $H_{n}$ and $H_{i}$ change by the same amount, so $t(i)$ is unchanged. - If $i=k$ and the coin is heads, $I_{i}$ goes down by 1 , as do both $\min \left\{i, H_{n}\right\}=H_{n}$ and $H_{i}$; so $t(i)$ goes down by 1 . - If $i=k$ and the coin is tails, $I_{i}$ goes up by $1, \min \left\{i, H_{n}\right\}=i$ is unchanged and $H_{i}$ goes up by 1 ; so $t(i)$ goes down by 1 .  We now need to compute the average value of  $$ \sum_{i=1}^{n} t(i)=\sum_{i=1}^{n} I_{i}+2 \sum_{i=1}^{n} \min \left\{i, H_{n}\right\}-2 \sum_{i=1}^{n} H_{i} . $$  The average value of the first term is $\frac{1}{2} n$, and that of the third term is $-\frac{1}{2} n(n+1)$. To compute the second term, we sum over choices for the total number of heads, and then over the possible values of $i$, getting  $$ 2^{1-n} \sum_{j=0}^{n}\binom{n}{j} \sum_{i=1}^{n} \min \{i, j\}=2^{1-n} \sum_{j=0}^{n}\binom{n}{j}\left(n j-\binom{j}{2}\right) . $$  Now, in terms of trinomial coefficients,  $$ \sum_{j=0}^{n} j\binom{n}{j}=\sum_{j=1}^{n}\binom{n}{n-j, j-1,1}=n \sum_{j=0}^{n-1}\binom{n-1}{j}=2^{n-1} n $$  and  $$ \sum_{j=0}^{n}\binom{j}{2}\binom{n}{j}=\sum_{j=2}^{n}\binom{n}{n-j, j-2,2}=\binom{n}{2} \sum_{j=0}^{n-2}\binom{n-2}{j}=2^{n-2}\binom{n}{2} $$  So the second term above is  $$ 2^{1-n}\left(2^{n-1} n^{2}-2^{n-2}\binom{n}{2}\right)=n^{2}-\frac{n(n-1)}{4} $$  and the required average is  $$ E(n)=\frac{1}{2} n+n^{2}-\frac{n(n-1)}{4}-\frac{1}{2} n(n+1)=\frac{n(n+1)}{4} . $$


Solution: Harry has built a Turing machine to flip the coins for him. The machine is initially positioned at the $k^{\text {th }}$ coin, where there are $k$ heads (and the position before the first coin is considered to be the $0^{\text {th }}$ coin). The machine then moves according to the following rules, stopping when it reaches the position before the first coin: if the coin at its current position is $H$, it flips the coin and moves to the previous coin, while if the coin at its current position is $T$, it flips the coin and moves to the next position.  Consider the maximal sequences of consecutive moves in the same direction. Suppose the machine has $a$ consecutive moves to the next coin, before a move to the previous coin. After those $a$ moves, the $a$ coins flipped in those moves are all heads, as is the coin the machine is now at, so at least the next $a+1$ moves will all be moves to the previous coin. Similarly, $a$ consecutive moves to the previous coin are followed by at least $a+1$ consecutive moves to the next coin. There cannot be more than $n$ consecutive moves in the same direction, so this proves that the process terminates (with a move from the first coin to the position before the first coin).  Thus we have a (possibly empty) sequence $a_{1}<\cdots<a_{t} \leqslant n$ giving the lengths of maximal sequences of consecutive moves in the same direction, where the final $a_{t}$ moves must be moves to the previous coin, ending before the first coin. We claim there is a bijection between initial configurations of the coins and such sequences. This gives  $$ E(n)=\frac{1}{2}(1+2+\cdots+n)=\frac{n(n+1)}{4} $$  as required, since each $i$ with $1 \leqslant i \leqslant n$ will appear in half of the sequences, and will contribute $i$ to the number of moves when it does.  To see the bijection, consider following the sequence of moves backwards, starting with the machine just before the first coin and all coins showing tails. This certainly determines a unique configuration of coins that could possibly correspond to the given sequence. Furthermore, every coin flipped as part of the $a_{j}$ consecutive moves is also flipped as part of all subsequent sequences of $a_{k}$ consecutive moves, for all $k>j$, meaning that, as we follow the moves backwards, each coin is always in the correct state when flipped to result in a move in the required direction. (Alternatively, since there are $2^{n}$ possible configurations of coins and $2^{n}$ possible such ascending sequences, the fact that the sequence of moves determines at most one configuration of coins, and thus that there is an injection from configurations of coins to such ascending sequences, is sufficient for it to be a bijection, without needing to show that coins are in the right state as we move backwards.)


Solution: We explicitly describe what happens with an arbitrary sequence $C$ of $n$ coins. Suppose that $C$ contain $k$ heads at positions $1 \leqslant c_{1}<c_{2}<\cdots<c_{k} \leqslant n$.  Let $i$ be the minimal index such that $c_{i} \geqslant k$. Then the first few steps will consist of turning over the $k^{\mathrm{th}},(k+1)^{\mathrm{th}}, \ldots, c_{i}^{\mathrm{th}},\left(c_{i}-1\right)^{\mathrm{th}},\left(c_{i}-2\right)^{\mathrm{th}}, \ldots, k^{\mathrm{th}}$ coins in this order. After that we get a configuration with $k-1$ heads at the same positions as in the initial one, except for $c_{i}$. This part of the process takes $2\left(c_{i}-k\right)+1$ steps.  After that, the process acts similarly; by induction on the number of heads we deduce that the process ends. Moreover, if the $c_{i}$ disappear in order $c_{i_{1}}, \ldots, c_{i_{k}}$, the whole process takes  $$ \ell(C)=\sum_{j=1}^{k}\left(2\left(c_{i_{j}}-(k+1-j)\right)+1\right)=2 \sum_{j=1}^{k} c_{j}-2 \sum_{j=1}^{k}(k+1-j)+k=2 \sum_{j=1}^{k} c_{j}-k^{2} $$  steps. Now let us find the total value $S_{k}$ of $\ell(C)$ over all $\binom{n}{k}$ configurations with exactly $k$ heads. To sum up the above expression over those, notice that each number $1 \leqslant i \leqslant n$ appears as $c_{j}$ exactly $\binom{n-1}{k-1}$ times. Thus  $$ \begin{gathered} S_{k}=2\binom{n-1}{k-1} \sum_{i=1}^{n} i-\binom{n}{k} k^{2}=2 \frac{(n-1) \cdots(n-k+1)}{(k-1)!} \cdot \frac{n(n+1)}{2}-\frac{n \cdots(n-k+1)}{k!} k^{2} \\ =\frac{n(n-1) \cdots(n-k+1)}{(k-1)!}((n+1)-k)=n(n-1)\binom{n-2}{k-1}+n\binom{n-1}{k-1} . \end{gathered} $$  Therefore, the total value of $\ell(C)$ over all configurations is  $$ \sum_{k=1}^{n} S_{k}=n(n-1) \sum_{k=1}^{n}\binom{n-2}{k-1}+n \sum_{k=1}^{n}\binom{n-1}{k-1}=n(n-1) 2^{n-2}+n 2^{n-1}=2^{n} \frac{n(n+1)}{4} $$  Hence the required average is $E(n)=\frac{n(n+1)}{4}$.


On a flat plane in Camelot, King Arthur builds a labyrinth $\mathfrak{L}$ consisting of $n$ walls,  each of which is an infinite straight line. No two walls are parallel, and no three walls have a common point. Merlin then paints one side of each wall entirely red and the other side entirely blue.  At the intersection of two walls there are four corners: two diagonally opposite corners where a red side and a blue side meet, one corner where two red sides meet, and one corner where two blue sides meet. At each such intersection, there is a two-way door connecting the two diagonally opposite corners at which sides of different colours meet.  After Merlin paints the walls, Morgana then places some knights in the labyrinth. The knights can walk through doors, but cannot walk through walls.  Let $k(\mathfrak{L})$ be the largest number $k$ such that, no matter how Merlin paints the labyrinth $\mathfrak{L}$, Morgana can always place at least $k$ knights such that no two of them can ever meet. For each $n$, what are all possible values for $k(\mathfrak{L})$, where $\mathfrak{L}$ is a labyrinth with $n$ walls? (Canada)  Answer: The only possible value of $k$ is $k=n+1$, no matter what shape the labyrinth is.

Solution: First we show by induction that the $n$ walls divide the plane into $\binom{n+1}{2}+1$ regions. The claim is true for $n=0$ as, when there are no walls, the plane forms a single region. When placing the $n^{\text {th }}$ wall, it intersects each of the $n-1$ other walls exactly once and hence splits each of $n$ of the regions formed by those other walls into two regions. By the induction hypothesis, this yields $\left(\binom{n}{2}+1\right)+n=\binom{n+1}{2}+1$ regions, proving the claim.  Now let $G$ be the graph with vertices given by the $\binom{n+1}{2}+1$ regions, and with two regions connected by an edge if there is a door between them.  We now show that no matter how Merlin paints the $n$ walls, Morgana can place at least $n+1$ knights. No matter how the walls are painted, there are exactly $\binom{n}{2}$ intersection points, each of which corresponds to a single edge in $G$. Consider adding the edges of $G$ sequentially and note that each edge reduces the number of connected components by at most one. Therefore the number of connected components of G is at least $\binom{n+1}{2}+1-\binom{n}{2}=n+1$. If Morgana places a knight in regions corresponding to different connected components of $G$, then no two knights can ever meet.  Now we give a construction showing that, no matter what shape the labyrinth is, Merlin can colour it such that there are exactly $n+1$ connected components, allowing Morgana to place at most $n+1$ knights.  First, we choose a coordinate system on the labyrinth so that none of the walls run due north-south, or due east-west. We then have Merlin paint the west face of each wall red, and the east face of each wall blue. We label the regions according to how many walls the region is on the east side of: the labels are integers between 0 and $n$.  We claim that, for each $i$, the regions labelled $i$ are connected by doors. First, we note that for each $i$ with $0 \leqslant i \leqslant n$ there is a unique region labelled $i$ which is unbounded to the north.  Now, consider a knight placed in some region with label $i$, and ask them to walk north (moving east or west by following the walls on the northern sides of regions, as needed). This knight will never get stuck: each region is convex, and so, if it is bounded to the north, it has a single northernmost vertex with a door northwards to another region with label $i$.  Eventually it will reach a region which is unbounded to the north, which will be the unique such region with label $i$. Hence every region with label $i$ is connected to this particular region, and so all regions with label $i$ are connected to each other.  As a result, there are exactly $n+1$ connected components, and Morgana can place at most $n+1$ knights.  Comment. Variations on this argument exist: some of them capture more information, and some of them capture less information, about the connected components according to this system of numbering.  For example, it can be shown that the unbounded regions are numbered $0,1, \ldots, n-1, n, n-1, \ldots, 1$ as one cycles around them, that the regions labelled 0 and $n$ are the only regions in their connected components, and that each other connected component forms a single chain running between the two unbounded ones. It is also possible to argue that the regions are acyclic without revealing much about their structure.


Solution: We give another description of a strategy for Merlin to paint the walls so that Morgana can place no more than $n+1$ knights.  Merlin starts by building a labyrinth of $n$ walls of his own design. He places walls in turn with increasing positive gradients, placing each so far to the right that all intersection points of previously-placed lines lie to the left of it. He paints each in such a way that blue is on the left and red is on the right.  For example, here is a possible sequence of four such lines $\ell_{1}, \ell_{2}, \ell_{3}, \ell_{4}$ : ![](https://cdn.mathpix.com/cropped/2024_11_18_9ee8c2ac2c2f5002ff14g-039.jpg?height=441&width=558&top_left_y=982&top_left_x=749)  We say that a region is "on the right" if it has $x$-coordinate unbounded above (note that if we only have one wall, then both regions are on the right). We claim inductively that, after placing $n$ lines, there are $n+1$ connected components in the resulting labyrinth, each of which contains exactly one region on the right. This is certainly true after placing 0 lines, as then there is only one region (and hence one connected component) and it is on the right.  When placing the $n^{\text {th }}$ line, it then cuts every one of the $n-1$ previously placed lines, and since it is to the right of all intersection points, the regions it cuts are exactly the $n$ regions on the right. ![](https://cdn.mathpix.com/cropped/2024_11_18_9ee8c2ac2c2f5002ff14g-039.jpg?height=495&width=518&top_left_y=1900&top_left_x=775)  The addition of this line leaves all previous connected components with exactly one region on the right, and creates a new connected component containing exactly one region, and that region is also on the right. As a result, by induction, this particular labyrinth will have $n+1$ connected components.  Having built this labyrinth, Merlin then moves the walls one-by-one (by a sequence of continuous translations and rotations of lines) into the proper position of the given labyrinth, in such a way that no two lines ever become parallel.  The only time the configuration is changed is when one wall is moved through an intersection point of two others: ![](https://cdn.mathpix.com/cropped/2024_11_18_9ee8c2ac2c2f5002ff14g-040.jpg?height=493&width=1472&top_left_y=353&top_left_x=289)  Note that all moves really do switch between two configurations like this: all sets of three lines have this colour configuration initially, and the rules on rotations mean they are preserved (in particular, we cannot create three lines creating a triangle with three red edges inwards, or three blue edges inwards).  However, as can be seen, such a move preserves the number of connected components, so in the painting this provides for Arthur's actual labyrinth, Morgana can still only place at most $n+1$ knights.  Comment. While these constructions are superficially distinct, they in fact result in the same colourings for any particular labyrinth. In fact, using the methods of Solution 2, it is possible to show that these are the only colourings that result in exactly $n+1$ connected components.


On a certain social network, there are 2019 users, some pairs of which are friends, where friendship is a symmetric relation. Initially, there are 1010 people with 1009 friends each and 1009 people with 1010 friends each. However, the friendships are rather unstable, so events of the following kind may happen repeatedly, one at a time:  Let $A, B$, and $C$ be people such that $A$ is friends with both $B$ and $C$, but $B$ and $C$ are not friends; then $B$ and $C$ become friends, but $A$ is no longer friends with them.  Prove that, regardless of the initial friendships, there exists a sequence of such events after which each user is friends with at most one other user. (Croatia) Common remarks. The problem has an obvious rephrasing in terms of graph theory. One is given a graph $G$ with 2019 vertices, 1010 of which have degree 1009 and 1009 of which have degree 1010. One is allowed to perform operations on $G$ of the following kind:  Suppose that vertex $A$ is adjacent to two distinct vertices $B$ and $C$ which are not adjacent to each other. Then one may remove the edges $A B$ and $A C$ from $G$ and add the edge $B C$ into $G$.  Call such an operation a refriending. One wants to prove that, via a sequence of such refriendings, one can reach a graph which is a disjoint union of single edges and vertices.  All of the solutions presented below will use this reformulation.

Solution: Note that the given graph is connected, since the total degree of any two vertices is at least 2018 and hence they are either adjacent or have at least one neighbour in common. Hence the given graph satisfies the following condition:  Every connected component of $G$ with at least three vertices is not complete and has a vertex of odd degree.  We will show that if a graph $G$ satisfies condition (1) and has a vertex of degree at least 2 , then there is a refriending on $G$ that preserves condition (1). Since refriendings decrease the total number of edges of $G$, by using a sequence of such refriendings, we must reach a graph $G$ with maximal degree at most 1 , so we are done. ![](https://cdn.mathpix.com/cropped/2024_11_18_9ee8c2ac2c2f5002ff14g-041.jpg?height=866&width=872&top_left_y=1891&top_left_x=592)  Pick a vertex $A$ of degree at least 2 in a connected component $G^{\prime}$ of $G$. Since no component of $G$ with at least three vertices is complete we may assume that not all of the neighbours of $A$ are adjacent to one another. (For example, pick a maximal complete subgraph $K$ of $G^{\prime}$. Some vertex $A$ of $K$ has a neighbour outside $K$, and this neighbour is not adjacent to every vertex of $K$ by maximality.) Removing $A$ from $G$ splits $G^{\prime}$ into smaller connected components $G_{1}, \ldots, G_{k}$ (possibly with $k=1$ ), to each of which $A$ is connected by at least one edge. We divide into several cases.  Case 1: $k \geqslant 2$ and $A$ is connected to some $G_{i}$ by at least two edges. Choose a vertex $B$ of $G_{i}$ adjacent to $A$, and a vertex $C$ in another component $G_{j}$ adjacent to $A$. The vertices $B$ and $C$ are not adjacent, and hence removing edges $A B$ and $A C$ and adding in edge $B C$ does not disconnect $G^{\prime}$. It is easy to see that this preserves the condition, since the refriending does not change the parity of the degrees of vertices.  Case 2: $k \geqslant 2$ and $A$ is connected to each $G_{i}$ by exactly one edge. Consider the induced subgraph on any $G_{i}$ and the vertex $A$. The vertex $A$ has degree 1 in this subgraph; since the number of odd-degree vertices of a graph is always even, we see that $G_{i}$ has a vertex of odd degree (in $G$ ). Thus if we let $B$ and $C$ be any distinct neighbours of $A$, then removing edges $A B$ and $A C$ and adding in edge $B C$ preserves the above condition: the refriending creates two new components, and if either of these components has at least three vertices, then it cannot be complete and must contain a vertex of odd degree (since each $G_{i}$ does).  Case 3: $k=1$ and $A$ is connected to $G_{1}$ by at least three edges. By assumption, $A$ has two neighbours $B$ and $C$ which are not adjacent to one another. Removing edges $A B$ and $A C$ and adding in edge $B C$ does not disconnect $G^{\prime}$. We are then done as in Case 1.  Case 4: $k=1$ and $A$ is connected to $G_{1}$ by exactly two edges. Let $B$ and $C$ be the two neighbours of $A$, which are not adjacent. Removing edges $A B$ and $A C$ and adding in edge $B C$ results in two new components: one consisting of a single vertex; and the other containing a vertex of odd degree. We are done unless this second component would be a complete graph on at least 3 vertices. But in this case, $G_{1}$ would be a complete graph minus the single edge $B C$, and hence has at least 4 vertices since $G^{\prime}$ is not a 4 -cycle. If we let $D$ be a third vertex of $G_{1}$, then removing edges $B A$ and $B D$ and adding in edge $A D$ does not disconnect $G^{\prime}$. We are then done as in Case 1. ![](https://cdn.mathpix.com/cropped/2024_11_18_9ee8c2ac2c2f5002ff14g-042.jpg?height=324&width=286&top_left_y=2208&top_left_x=885)  Comment. In fact, condition 1 above precisely characterises those graphs which can be reduced to a graph of maximal degree $\leqslant 1$ by a sequence of refriendings.


Solution: As in the previous solution, note that a refriending preserves the property that a graph has a vertex of odd degree and (trivially) the property that it is not complete; note also that our initial graph is connected. We describe an algorithm to reduce our initial graph to a graph of maximal degree at most 1, proceeding in two steps.  Step 1: There exists a sequence of refriendings reducing the graph to a tree. Proof. Since the number of edges decreases with each refriending, it suffices to prove the following: as long as the graph contains a cycle, there exists a refriending such that the resulting graph is still connected. We will show that the graph in fact contains a cycle $Z$ and vertices $A, B, C$ such that $A$ and $B$ are adjacent in the cycle $Z, C$ is not in $Z$, and is adjacent to $A$ but not $B$. Removing edges $A B$ and $A C$ and adding in edge $B C$ keeps the graph connected, so we are done. ![](https://cdn.mathpix.com/cropped/2024_11_18_9ee8c2ac2c2f5002ff14g-043.jpg?height=381&width=489&top_left_y=863&top_left_x=778)  To find this cycle $Z$ and vertices $A, B, C$, we pursue one of two strategies. If the graph contains a triangle, we consider a largest complete subgraph $K$, which thus contains at least three vertices. Since the graph itself is not complete, there is a vertex $C$ not in $K$ connected to a vertex $A$ of $K$. By maximality of $K$, there is a vertex $B$ of $K$ not connected to $C$, and hence we are done by choosing a cycle $Z$ in $K$ through the edge $A B$. ![](https://cdn.mathpix.com/cropped/2024_11_18_9ee8c2ac2c2f5002ff14g-043.jpg?height=380&width=498&top_left_y=1586&top_left_x=776)  If the graph is triangle-free, we consider instead a smallest cycle $Z$. This cycle cannot be Hamiltonian (i.e. it cannot pass through every vertex of the graph), since otherwise by minimality the graph would then have no other edges, and hence would have even degree at every vertex. We may thus choose a vertex $C$ not in $Z$ adjacent to a vertex $A$ of $Z$. Since the graph is triangle-free, it is not adjacent to any neighbour $B$ of $A$ in $Z$, and we are done.  Step 2: Any tree may be reduced to a disjoint union of single edges and vertices by a sequence of refriendings. Proof. The refriending preserves the property of being acyclic. Hence, after applying a sequence of refriendings, we arrive at an acyclic graph in which it is impossible to perform any further refriendings. The maximal degree of any such graph is 1 : if it had a vertex $A$ with two neighbours $B, C$, then $B$ and $C$ would necessarily be nonadjacent since the graph is cycle-free, and so a refriending would be possible. Thus we reach a graph with maximal degree at most 1 as desired.


Let $n>1$ be an integer. Suppose we are given $2 n$ points in a plane such that no three of them are collinear. The points are to be labelled $A_{1}, A_{2}, \ldots, A_{2 n}$ in some order. We then consider the $2 n$ angles $\angle A_{1} A_{2} A_{3}, \angle A_{2} A_{3} A_{4}, \ldots, \angle A_{2 n-2} A_{2 n-1} A_{2 n}, \angle A_{2 n-1} A_{2 n} A_{1}$, $\angle A_{2 n} A_{1} A_{2}$. We measure each angle in the way that gives the smallest positive value (i.e. between $0^{\circ}$ and $180^{\circ}$ ). Prove that there exists an ordering of the given points such that the resulting $2 n$ angles can be separated into two groups with the sum of one group of angles equal to the sum of the other group.  Comment. The first three solutions all use the same construction involving a line separating the points into groups of $n$ points each, but give different proofs that this construction works. Although Solution 1 is very short, the Problem Selection Committee does not believe any of the solutions is easy to find and thus rates this as a problem of medium difficulty.

Solution: Let $\ell$ be a line separating the points into two groups ( $L$ and $R$ ) with $n$ points in each. Label the points $A_{1}, A_{2}, \ldots, A_{2 n}$ so that $L=\left\{A_{1}, A_{3}, \ldots, A_{2 n-1}\right\}$. We claim that this labelling works.  Take a line $s=A_{2 n} A_{1}$. (a) Rotate $s$ around $A_{1}$ until it passes through $A_{2}$; the rotation is performed in a direction such that $s$ is never parallel to $\ell$. (b) Then rotate the new $s$ around $A_{2}$ until it passes through $A_{3}$ in a similar manner. (c) Perform $2 n-2$ more such steps, after which $s$ returns to its initial position.  The total (directed) rotation angle $\Theta$ of $s$ is clearly a multiple of $180^{\circ}$. On the other hand, $s$ was never parallel to $\ell$, which is possible only if $\Theta=0$. Now it remains to partition all the $2 n$ angles into those where $s$ is rotated anticlockwise, and the others.


Solution: When tracing a cyclic path through the $A_{i}$ in order, with straight line segments between consecutive points, let $\theta_{i}$ be the exterior angle at $A_{i}$, with a sign convention that it is positive if the path turns left and negative if the path turns right. Then $\sum_{i=1}^{2 n} \theta_{i}=360 k^{\circ}$ for some integer $k$. Let $\phi_{i}=\angle A_{i-1} A_{i} A_{i+1}($ indices $\bmod 2 n)$, defined as in the problem; thus $\phi_{i}=180^{\circ}-\left|\theta_{i}\right|$.  Let $L$ be the set of $i$ for which the path turns left at $A_{i}$ and let $R$ be the set for which it turns right. Then $S=\sum_{i \in L} \phi_{i}-\sum_{i \in R} \phi_{i}=(180(|L|-|R|)-360 k)^{\circ}$, which is a multiple of $360^{\circ}$ since the number of points is even. We will show that the points can be labelled such that $S=0$, in which case $L$ and $R$ satisfy the required condition of the problem.  Note that the value of $S$ is defined for a slightly larger class of configurations: it is OK for two points to coincide, as long as they are not consecutive, and OK for three points to be collinear, as long as $A_{i}, A_{i+1}$ and $A_{i+2}$ do not appear on a line in that order. In what follows it will be convenient, although not strictly necessary, to consider such configurations.  Consider how $S$ changes if a single one of the $A_{i}$ is moved along some straight-line path (not passing through any $A_{j}$ and not lying on any line $A_{j} A_{k}$, but possibly crossing such lines). Because $S$ is a multiple of $360^{\circ}$, and the angles change continuously, $S$ can only change when a point moves between $R$ and $L$. Furthermore, if $\phi_{j}=0$ when $A_{j}$ moves between $R$ and $L, S$ is unchanged; it only changes if $\phi_{j}=180^{\circ}$ when $A_{j}$ moves between those sets.  For any starting choice of points, we will now construct a new configuration, with labels such that $S=0$, that can be perturbed into the original one without any $\phi_{i}$ passing through $180^{\circ}$, so that $S=0$ for the original configuration with those labels as well.  Take some line such that there are $n$ points on each side of that line. The new configuration has $n$ copies of a single point on each side of the line, and a path that alternates between sides of the line; all angles are 0 , so this configuration has $S=0$. Perturbing the points into their original positions, while keeping each point on its side of the line, no angle $\phi_{i}$ can pass through $180^{\circ}$, because no straight line can go from one side of the line to the other and back. So the perturbation process leaves $S=0$.  Comment. More complicated variants of this solution are also possible; for example, a path defined using four quadrants of the plane rather than just two half-planes.