exam: INMO

problem:
Let $S$ be a finite set of positive integers. Assume that there are precisely 2023 ordered pairs $(x, y)$ in $S \times S$ so that the product $x y$ is a perfect square. Prove that one can find at least four distinct elements in $S$ so that none of their pairwise products is a perfect square.

Note: As an example, if $S=\{1,2,4\}$, there are exactly five such ordered pairs: $(1,1),(1,4)$, $(2,2),(4,1)$, and $(4,4)$.

solution:
Consider the graph whose vertices are elements of $S$, with an edge between $x$ and $y$ if and only if $x y$ is a perfect square. We claim every connected component is a clique.

Indeed, take any two vertices corresponding to $x, y$ in $S$ in the same connected component. It suffices to show they are adjacent. By assumption, there is a path between them; so there is a sequence $x=a_{1}, a_{2}, \ldots, a_{n-1}, a_{n}=y$ so that $a_{i} a_{i+1}$ is a perfect square for $1 \leq i<n$. Therefore

$$
x y=a_{1} a_{n}=\frac{\left(a_{1} a_{2}\right)\left(a_{2} a_{3}\right) \cdots\left(a_{n-1} a_{n}\right)}{a_{2}^{2} \cdots a_{n-1}^{2}}
$$

is a perfect square as well. This proves our claim.

Now suppose first there are at most 3 connected components, with sizes $a, b, c$ (possibly zero). Note that for $(x, y) \in S \times S, x y$ is a perfect square if and only if $x, y$ are in the same component, which can be chosen is $a^{2}+b^{2}+c^{2}$ ways. Thus

$$
a^{2}+b^{2}+c^{2}=2023
$$

But since squares can only be 0,1 or $4 \bmod 8$, and 2023 is $7 \bmod 8$, the above equation is impossible. Thus our graph must have at least four components. Picking a number from each component, we can now satisfy the requirements of the problem.

problem_match: Problem 1.

solution_match: Solution 1.


solution:
For $a$ in $S$, let $S_{a}=\{x \in S \mid a x$ is a square $\}$. Let $a, b$ be elements of $S$. Suppose that $x$ is in $S_{a} \cap S_{b}$. Then $a x$ and $b x$ are squares and hence $a b=\frac{a x \cdot b x}{x^{2}}$ is a square. Then for any $y$ in $S$ such that $a y$ is a square it follows that by is a square, so $S_{a}=S_{b}$. Hence for two elements $a, b$ in $S$, either $S_{a}=S_{b}$ or $S_{a} \cap S_{b}=\emptyset$.

Now, $S=\cup S_{a}$ where the union runs over elements of $S$ (since $a \in S_{a}$ for any $a \in S$ ). Let $S=S_{a_{1}} \cup S_{a_{2}} \cup \cdots \cup S_{a_{n}}$ for some elements $a_{1}, a_{2}, \ldots, a_{n}$ of $S$ such that $S_{a_{i}} \cap S_{a_{j}}=\emptyset$ for $1 \leq i<j \leq n$. Then the number of distinct pairs $(x, y)$ of $S \times S$ such that $x y$ is a square is precisely $\left|S_{a_{1}}\right|^{2}+\left|S_{a_{2}}\right|^{2}+\cdots+\left|S_{a_{n}}\right|^{2}$. Since $2023 \equiv 7(\bmod 8)$ it follows that $n>3$ as in the previous solution. Thus we have four elements $a_{1}, a_{2}, a_{3}, a_{4}$ none of whose pairwise products is a square.

For those familiar with the language of linear algebra and finite fields, the above argument can be reformulated as follows:

solution_match: Solution 2.


solution:
Let $p_{1}<p_{2}<\ldots$ be the sequence of prime numbers. Denote by $\mathbb{F}_{2}^{\omega}$ the $\mathbb{F}_{2}$ vector space of all binary sequences $\left(a_{1}, a_{2}, \ldots\right)$ with entries in $\mathbb{F}_{2}$. Consider the set map $\Phi: \mathbb{N} \rightarrow \mathbb{F}_{2}^{\omega}$ defined by

$$
\Phi(n):=\left(v_{p_{i}}(n) \quad(\bmod 2)\right)_{i \geq 1}
$$

for all $n \in \mathbb{N}$. It is clear that for $x, y \in \mathbb{N}$, the product $x y$ is a perfect square if and only if $\Phi(x)=\Phi(y)$. So we want $|\Phi(S)| \geq 4$. Indeed, decompose $S$ as a union of fibres, $S=\cup_{a \in \Phi(S)} \Phi^{-1}(a)$. Each fibre with size $r$ accounts for $2\binom{r}{2}+r=r^{2}$ pairs towards the count, so if $\Phi(S)$ has at most three elements, then $a^{2}+b^{2}+c^{2}=2023$ has a solution in non-negative integers. This is a contradiction mod 8 , by simply checking that no triple formed using one of $\{0,1,4\}$ can add to $7 \bmod 8$.

solution_match: Solution 3.


problem:
Suppose $a_{0}, \ldots, a_{100}$ are positive reals. Consider the following polynomial for each $k$ in $\{0,1, \ldots, 100\}$ :

$$
a_{100+k} x^{100}+100 a_{99+k} x^{99}+a_{98+k} x^{98}+a_{97+k} x^{97}+\cdots+a_{2+k} x^{2}+a_{1+k} x+a_{k}
$$

where indices are taken modulo 101, i.e., $a_{100+i}=a_{i-1}$ for any $i$ in $\{1,2, \ldots, 100\}$. Show that it is impossible that each of these 101 polynomials has all its roots real.

solution:
Let $n=50$. For the sake of contradiction, assume that each of these polynomials has all real roots; these roots must be negative. Let

$$
-\alpha_{1, k},-\alpha_{2, k}, \ldots,-\alpha_{2 n, k}
$$

be the roots of the polynomial

$$
a_{2 n+k} x^{2 n}+2 n a_{2 n-1+k} x^{2 n-1}+a_{2 n-2+k} x^{2 n-2}+a_{2 n-3+k} x^{2 n-3}+\cdots+a_{2+k} x^{2}+a_{1+k} x+a_{k}
$$

Indices are taken modulo $2 n+1$, so $a_{2 n+k}=a_{k-1}$ and $a_{2 n-1+k}=a_{k-2}$. Then

$$
\sum_{j=1}^{2 n} \alpha_{j, k}=2 n \cdot\left(\frac{a_{k-2}}{a_{k-1}}\right) ; \prod_{j=1}^{2 n} \alpha_{j, k}=\frac{a_{k}}{a_{k-1}}
$$

Since the $\alpha_{j, k}$ 's are positive, AM-GM inequality can be applied and by virtue of it we are led to

$$
\left(\frac{a_{k-2}}{a_{k-1}}\right)^{2 n} \geq \frac{a_{k}}{a_{k-1}}
$$

for each $k$. As both sides of the inequalities are positive, multiplying them we obtain

$$
\prod_{k=0}^{2 n}\left(\frac{a_{k-2}}{a_{k-1}}\right)^{2 n} \geq \prod_{k=0}^{2 n} \frac{a_{k}}{a_{k-1}}
$$

But both sides are equal to 1 . Therefore all the $2 n+1$ A.M-G.M inequalities are equalities implying that for each $k$,

$$
\alpha_{1, k}=\alpha_{2, k}=\ldots=\alpha_{2 n, k}=\frac{a_{k-2}}{a_{k-1}}
$$

Since $n \geq 2$, using Vieta's relations gives

$$
\frac{a_{k-3}}{a_{k-1}}=\sum_{1 \leq i<j \leq 2 n} \alpha_{i, k} \alpha_{j, k}=\binom{2 n}{2}\left(\frac{a_{k-2}}{a_{k-1}}\right)^{2}
$$

Simplifying leads

$$
\binom{2 n}{2} a_{k-2}^{2}=a_{k-1} a_{k-3}
$$

for each $k$. Multiplying all these equations yields

$$
\left(\binom{2 n}{2}^{2 n+1}-1\right)\left(\prod_{k=0}^{2 n} a_{k}\right)^{2}=0
$$

which shows that at least one $a_{k}=0$, a contradiction.

problem_match: Problem 2.


solution:
As above, one proves that

$$
\alpha_{1, k}=\alpha_{2, k}=\ldots=\alpha_{2 n, k}=\frac{a_{k-2}}{a_{k-1}}
$$

This implies

$$
a_{2 n+k} x^{2 n}+2 n a_{2 n-1+k} x^{2 n-1}+\cdots+a_{1+k} x+a_{k}=a_{2 n+k}\left(x+\frac{a_{k-2}}{a_{k-1}}\right)^{2 n}
$$

For $n \geq 2$, comparing coefficients of $x^{0}$ and $x^{1}$, we see that

$$
a_{k}=a_{2 n+k}\left(\frac{a_{k-2}}{a_{k-1}}\right)^{2 n}, \quad a_{k+1}=a_{2 n+k} \cdot 2 n\left(\frac{a_{k-2}}{a_{k-1}}\right)^{2 n-1}
$$

whence we obtain

$$
\frac{a_{k+1}}{a_{k}}=2 n \cdot \frac{a_{k-1}}{a_{k-2}}
$$

This must hold for all $k$. However, if we pick $k$ is such that $\frac{a_{k+1}}{a_{k}}$ is minimal, we must necessarily have

$$
\frac{a_{k+1}}{a_{k}} \leq \frac{a_{k-1}}{a_{k-2}}<2 n \cdot \frac{a_{k-1}}{a_{k-2}}
$$

a contradiction.

Several other beautiful solutions were pointed out to us; we include a few of them.


solution:
As usual, assume all of these polynomials have all real roots. We consider the polynomial obtained by writing the coefficients of the given polynomials in reverse order:

$$
a_{k} x^{100}+a_{k+1} x^{99}+a_{k+2} x^{98}+\cdots+100 a_{k+99} x+a_{k+100}
$$

This also has all its roots real: in fact, its roots are reciprocals of the original polynomial. By Rolle's theorem, its derivative must also have all roots real. Repeating this argument, we see that the polynomial obtained by differentiating this 98 times

$$
\frac{100!}{2!} a_{k} x^{2}+99!a_{k+1} x+98!a_{k+2}
$$

also have real roots. Therefore this must have nonnegative discriminant:

$$
99!^{2} a_{k+1}^{2} \geq 2 \cdot 98!\cdot 100!a_{k} a_{k+2}
$$

which simplifies to

$$
99 a_{k+1}^{2} \geq 200 a_{k} a_{k+2}
$$

This holds for all $k$, so multiplying these as $k$ varies, we obtain

$$
99^{101} \prod_{i=0}^{100} a_{i}^{2} \geq 200^{101} \prod_{i=0}^{100} a_{i}^{2}
$$

which is impossible since $99<200$.


solution:
Choose $k$ so that $a_{k+1}$ is minimal. As before, consider the polynomial

$$
a_{k} x^{100}+a_{k+1} x^{99}+a_{k+2} x^{98}+\cdots+100 a_{k+99} x+a_{k+100}
$$

and suppose its roots are $\beta_{1}, \cdots, \beta_{100}$. We have, by Vieta's relations,

$$
\sum_{i=1}^{100} \beta_{i}=-\frac{a_{k+1}}{a_{k}}, \quad \sum_{1 \leq i<j \leq n} \beta_{i} \beta_{j}=\frac{a_{k+2}}{a_{k}}
$$

However, we note that

$$
\left(\sum_{i=1}^{100} \beta_{i}\right)^{2}=\sum_{i=1}^{100} \beta_{i}^{2}+2 \sum_{1 \leq i<j \leq n} \beta_{i} \beta_{j} \geq 2 \sum_{1 \leq i<j \leq n} \beta_{i} \beta_{j}
$$

which yields

$$
\left(-\frac{a_{k+1}}{a_{k}}\right)^{2} \geq \frac{2 a_{k+2}}{a_{k}}
$$

This simplifies to $a_{k+1}^{2} \geq 2 a_{k} a_{k+2}$. However, by the choice of $k$, we have

$$
a_{k+1}^{2} \leq a_{k} a_{k+2}<2 a_{k} a_{k+2}
$$

a contradiction.

solution_match: Solution 4.


problem:
Let $\mathbb{N}$ denote the set of all positive integers. Find all real numbers $c$ for which there exists a function $f: \mathbb{N} \rightarrow \mathbb{N}$ satisfying:

(a) for any $x, a \in \mathbb{N}$, the quantity $\frac{f(x+a)-f(x)}{a}$ is an integer if and only if $a=1$;

(b) for all $x \in \mathbb{N}$, we have $|f(x)-c x|<2023$.

solution:
We claim that the only possible values of $c$ are $k+\frac{1}{2}$ for some non-negative integer $k$. The fact that these values are possible is seen from the function $f(x)=$ $\left\lfloor\left(k+\frac{1}{2}\right) x\right\rfloor+1=k x+\left\lfloor\frac{x}{2}\right\rfloor+1$. Indeed, if you have any $x, a \in \mathbb{N}$, then

$$
\frac{f(x+a)-f(x)}{a}=\frac{1}{a}\left(k a+\left\lfloor\frac{x+a}{2}\right\rfloor-\left\lfloor\frac{x}{2}\right\rfloor\right)=k+\frac{1}{a}\left(\left\lfloor\frac{x+a}{2}\right\rfloor-\left\lfloor\frac{x}{2}\right\rfloor\right)
$$

This is clearly an integer for $a=1$. But for $a \geq 2$, we have

$$
\left\lfloor\frac{x+a}{2}\right\rfloor-\left\lfloor\frac{x}{2}\right\rfloor \geq\left\lfloor\frac{x+2}{2}\right\rfloor-\left\lfloor\frac{x}{2}\right\rfloor=1
$$

If $a=2 k$, then

$$
\left\lfloor\frac{x+a}{2}\right\rfloor-\left\lfloor\frac{x}{2}\right\rfloor=k<2 k=a
$$

and if $a=2 k+1$ for $k \geq 1$, then

$$
\left\lfloor\frac{x+a}{2}\right\rfloor-\left\lfloor\frac{x}{2}\right\rfloor \leq\left\lfloor\frac{x+2 k+2}{2}\right\rfloor-\left\lfloor\frac{x}{2}\right\rfloor=k+1<2 k+1=a
$$

So in either case, the quantity $\left\lfloor\frac{x+a}{2}\right\rfloor-\left\lfloor\frac{x}{2}\right\rfloor$ is strictly between 0 and $a$, and thus cannot be divisible by $a$. Thus condition (a) holds; condition (b) is obviously true.

Now let us show these are the only possible values, under the weaker assumption that there exists some $d \in \mathbb{N}$ so that $|f(x)-c x|<d$. It is clear that $c \geq 0$ : if $-d<f(x)-c x<d$ and $c<0$, then for large $x$ the range $[c x-d, c x+d]$ consists only of negative numbers and cannot contain $f(x)$.

Now we claim that $c \geq \frac{1}{2}$. Indeed, suppose that $0 \leq c<\frac{1}{2}$, and that $d>0$ is such that $|f(x)-c x| \leq d$. Pick $N>\frac{2 d}{1-2 c}$ so that $2(c N+d)<N$. Then the $N$ values $\{f(1), \ldots, f(N)\}$ must be all be in the range $\{1, \ldots, c N+d\}$, and by pigeonhole principle, some three values $f(i), f(j), f(k)$ must be equal. Some two of $i, j, k$ are not consecutive: suppose WLOG $i>j+1$. Then $\frac{f(i)-f(j)}{i-j}=0$, which contradicts condition (a) for $x=j$ and $a=i-j$.

Now for the general case, suppose $c=k+\lambda$, where $k \in \mathbb{Z}$ and $\lambda \in[0,1)$. Let $d \in \mathbb{N}$ be such that $-d \leq f(x)-c x \leq d$. Consider the functions

$$
g_{1}(x)=f(x)-k x+d+1, g_{2}(x)=x-f(x)+k x+d+1
$$

Note that

$$
\begin{gathered}
g_{1}(x) \geq c x-d-k x+d+1=\lambda x+1 \geq 1 \\
g_{2}(x) \geq x-(c x+d)+k x+d+1=(1-\lambda) x+1 \geq 1
\end{gathered}
$$

so that these are also functions from $\mathbb{N}$ to $\mathbb{N}$. They also satisfy condition (a) for $f$ :

$$
\frac{g_{1}(x+a)-g_{1}(x)}{a}=\frac{f(x+a)-k(x+a)+d-f(x)+k x-d}{a}=\frac{f(x+a)-f(x)}{a}-k
$$

is an integer if and only if $\frac{f(x+a)-f(x)}{a}$ is, which happens if and only if $a=1$. A similar argument holds for $g_{2}$.

Now note that $g_{1}(x)-\lambda x=f(x)-c x+d+1$ is bounded, and so is $g_{2}(x)-(1-\lambda) x=$ $c x-f(x)+d+1$. So they satisfy the weaker form of condition (b) as well. Thus applying the reasoning in the second paragraph, we see that $\lambda \geq \frac{1}{2}$ and $1-\lambda \geq \frac{1}{2}$. This forces $\lambda=\frac{1}{2}$, which finishes our proof.

problem_match: Problem 3.


solution:
We will show that for any such $c$, we have $c>0$ and $\{c\}=\frac{1}{2}$. Also 2023 can be replaced by any fixed $d \geq 1$ in condition $(b)$ which we assume now.

Clearly $c \geq 0$ else for $c<0$ and $x>\frac{d}{|c|}, c x-d<f(x)<c x+d<0$ which is a contradiction. Suppose $\{c\} \neq \frac{1}{2}$. Put $r=\lfloor c\rfloor$ and $\lambda=\min (\{c\}, 1-\{c\})$ and define

$$
g(x)= \begin{cases}f(x)-r x & \text { if }\{c\}<\frac{1}{2} \\ x+r x-f(x) & \text { if }\{c\}>\frac{1}{2}\end{cases}
$$

so that $|f(x)-c x|=|g(x)-\lambda x|$ and $g(x) \in \mathbb{Z}$ for all $x \in \mathbb{N}$. Here $0 \leq \lambda<\frac{1}{2}$. Take $N>2(\lambda N+2 d)$. Then from $|g(x)-\lambda x|=|f(x)-c x|<d$, we get

$$
-d \leq \lambda n-d<g(n)<\lambda n+d \leq \lambda N+d
$$

for all $1 \leq n \leq N$. That is $N$ integers $g(n), 1 \leq n \leq N$ can take at most $\lambda N+2 d$ values. Since $N>2(\lambda N+2 d)$, by pigeonhole principle, there are 3 positive integers $i<j<k$ such that $g(i)=g(j)=g(k)$. Then $k-i \geq 2$ and

$$
f(k)-f(i)= \begin{cases}g(k)+r k-(g(i)+r i)=r(k-i) & \text { if }\{c\}<\frac{1}{2} \\ (1+r) k-g(k)-((1+r) i-g(i))=(1+r)(k-i) & \text { if }\{c\}>\frac{1}{2}\end{cases}
$$

so that $\frac{f(k)-f(i)}{k-i}$ is an integer. This contradicts the condition $(a)$. Also for each $c=k+\frac{1}{2}$, the function $f(x)=\left\lfloor\left(k+\frac{1}{2}\right) x\right\rfloor$ satisfy the conditions $(a)$ and $(b)$.


solution:
We give a different proof that $\{c\}=1 / 2$. Let us first prove a claim:

Claim. For any $k \geq 1$ and any $x, f\left(x+2^{k}\right)-f(x)$ is divisible by $2^{k-1}$ but not $2^{k}$.

Proof. We prove this via induction on $k$. For $k=1$, the claim is trivial. Now assume the statement is true for some $k$, and note that $f\left(x+2^{k}\right)-f(x)=2^{k-1} y_{1}$ and $f\left(x+2^{k}+2^{k}\right)-$ $f\left(x+2^{k}\right)=2^{k-1} y_{2}$ for some odd integers $y_{1}, y_{2}$. Adding these, we see that

$$
f\left(x+2^{k+1}\right)-f(x)=2^{k-1}\left(y_{1}+y_{2}\right)
$$

which is divisible by $2^{k}$ because $y_{1}+y_{2}$ is even. The fact that this is not divisible by $2^{k+1}$ follows from the condition on $f$.

Now using this claim, we see that for any $k \geq 1, f\left(1+2^{k}\right)=f(1)+2^{k-1}\left(2 y_{k}+1\right)$ for some integer $y_{k}$, which means

$$
f\left(1+2^{k}\right)-c\left(1+2^{k}\right)=f(1)-c+2^{k}\left(y_{k}+\frac{1}{2}-c\right)
$$

Thus $2^{k}\left(y_{k}+\frac{1}{2}-c\right)$ is bounded. But $y_{k}+\frac{1}{2}-c$ has the same fractional part as $\frac{1}{2}-c$, so if this quantity is never zero, its absolute value must be at least $m=\min \left(\left\{\frac{1}{2}-c\right\},\left\{c-\frac{1}{2}\right\}\right)$ and thus we have

$$
2^{k}\left|y_{k}+\frac{1}{2}-c\right| \geq 2^{k} m
$$

contradicting boundedness. Thus we must have $y_{k}+\frac{1}{2}-c=0$ for some $k$. Since $y_{k}$ is an integer, so that $\{c\}=\frac{1}{2}$.

A more rigorous treatment is given below.

Obtain

$$
f\left(1+2^{k}\right)-c\left(1+2^{k}\right)=f(1)-c-2^{k}\left(y_{k}+\frac{1}{2}-c\right)
$$

as before. We obtain that $2^{k}\left|y_{k}+\frac{1}{2}-c\right| \leq M$ for some $M>0$ by condition (b). Suppose that $\{c\} \neq \frac{1}{2}$. Writing $y_{k}+\frac{1}{2}-c=m_{k}+\delta$ with $m_{k} \in \mathbb{Z}$ and $0 \leq \delta<1$, we have $0<\delta<1$. Then there exists $\ell>1$ such that $\min (\delta, 1-\delta) \geq \frac{1}{2^{\ell}}$. Hence

$$
\left|y_{k}+\frac{1}{2}-c\right|=\left|m_{k}+\delta\right| \geq \begin{cases}\delta \geq \frac{1}{2^{\ell}} & \text { if } m_{k} \geq 0 \\ -m_{k}-\delta \geq 1-\delta \geq \frac{1}{2^{\ell}} & \text { if } m_{k}<0\end{cases}
$$

implying $M \geq 2^{k}\left|y_{k}+\frac{1}{2}-c\right| \geq 2^{k-\ell}$ which is a contradiction for large $k$. Thus $\{c\}=\frac{1}{2}$.


problem: Let $k \geq 1$ and $N>1$ be two integers. On a circle are placed $2 N+1$ coins all showing heads. Calvin and Hobbes play the following game. Calvin starts and on his move can turn any coin from heads to tails. Hobbes on his move can turn at most one coin that is next to the coin that Calvin turned just now from tails to heads. Calvin wins if at any moment there are $k$ coins showing tails after Hobbes has made his move. Determine all values of $k$ for which Calvin wins the game.

solution:
Calvin wins if $k \in\{1,2, \ldots, N+1\}$ and Hobbes wins otherwise.

Label the coins $1,2, \ldots, 2 N+1$. Note that if $k \geq N+2$ then Hobbes wins as follows: he pairs the coins $2 i-1$ and $2 i$ for $1 \leq i \leq N$. If Calvin in a move makes both coins in a pair tails, Hobbes in that move turns the one which was tails prior to Calvin's move back to heads. Thus, he can ensure that after his move, no pair has more than one tails. So, the number of tails after his move is $\leq 1+\frac{(2 N+1)-1}{2}=N+1$, hence Hobbes wins. If $k \leq N$, then Calvin wins by simply turning coins $2 i$ for $1 \leq i \leq N$. Now let $k=N+1$.

Let $N=2 m+\varepsilon$ where $\varepsilon \in\{0,1\}$. Now consider $m$ arcs on the circle with the $i$ th arc containing $\{4 i+1,4 i+2,4 i+3,4 i+4\}$, for all $0 \leq i<m$. Calvin makes $3 m$ moves as follows: on move $3 i+1,3 i+2$, and $3 i+3$, he turns coins numbered $4 i+2,4 i+4$, and $4 i+3$, respectively, to tails, for all $0 \leq i<m$. Thus, no matter what Hobbes does, each arc will have either $\{4 i+2,4 i+3\}$ tails (type $\widehat{23}$ ), or $\{4 i+3,4 i+4\}$ tails (type $\widehat{34}$ ), or all of $\{4 i+2,4 i+3,4 i+4\}$ tails (type $\widehat{234}$ ), by the end of these $3 \mathrm{~m}$ moves. We now split into cases:

Case 1. $\varepsilon=0$ In this case, if we have any arc of type $\widehat{234}$, we get that there are $\geq 3+2(m-1)=N+1$ tails at the end and the game is won. Assume all arcs are of type $\widehat{23}$ or $\widehat{34}$; hence we currently have $2 m$ tails. Now, if $4 m+1$ has no tails neighbours, Calvin turns it to win. So assume the arc $\{4 m-3,4 m-2,4 m-1,4 m\}$ is of type $\widehat{34}$. If $\{1,2,3,4\}$ is also of type $\widehat{34}$, Calvin can turn 1 to tails to win as it has no tails neighbours. If it is of type $\widehat{23}$, then we must have an $0 \leq i<m-1$ such that the $i$ th arc is of type $\widehat{23}$ but the $(i+1)$ th arc is of type $\widehat{34}$, which means that Calvin can turn $4 i+1$ to tails to win, as it has no tails neighbours.

Case 2. $\varepsilon=1 \quad$ Again, if we have any arc of type $\widehat{234}$, Calvin turns $4 m+2$ and we end up with $\geq 3+2(m-1)+1=N+1$ tails at the end and the game is won. Assume all arcs are of type $\widehat{23}$ or $\widehat{34}$; hence we currently have $2 m$ tails. If Calvin can turn $4 m+1$, then he wins, by turning $4 m+3$ next move; so assume the arc $\{4 m-3,4 m-2,4 m-1,4 m\}$ is of type $\widehat{34}$. If $\{1,2,3,4\}$ is of type $\widehat{34}$, then Calvin can turn 1 and $4 m+2$ to secure his win; so assume $\{1,2,3,4\}$ is of type $\widehat{23}$. Thus, there exists $0 \leq i<m-1$ such that the $i$ th arc is of type $\widehat{23}$ and the $(i+1)$ th arc is of type $\widehat{34}$, hence Calvin wins by turning $4 m+2$ and $4 i+1$, in the next two moves.

In conclusion, Calvin wins if $k=N+1$, completing the proof.

Again, we include some remarkable alternative solutions that were brought to our attention.

problem_match: Problem 4.


solution:
As before, we can prove that Hobbes wins for $k \geq N+2$. It remains to show that Calvin can win for $k=N+1$.

Let Calvin turn the $N$ coins labeled $1,3, \cdots, 2 N-1$ in order. Note that no two coins showing tails are adjacent at any point till now, so Hobbes cannot change any of them back to heads. On the next move, let Calvin turn coin 2 to tails. Now if Hobbes turns coin 1 to heads, Calvin can turn coin $2 N+1$ to tails and win. If Hobbes turns coin 3 to heads instead, let Calvin turn the even-numbered coins $4,6, \cdots, 2 N-2$ in order. After Calvin flips the coin $2 k$, Hobbes must respond by flipping $2 k+1$ after each move to avoid losing. Therefore after these moves, the $N$ coins $1,2,4, \cdots, 2 N-2$ are showing tails, so now Calvin can turn $2 N$ and win.


solution: Again we show a procedure for Calvin to win for $k=N+1$. Let Calvin turn coins 1 and 3 tails, and then coin 2 to tails. Hobbes must respond by turning one of 1 or 3 back to heads. In any case, Calvin secures two consecutive tails at the end of Hobbes' turn. He removes these two coins and their neighbours; and from the $(2 N+1)-4=2 N-3$ remaining coins, he turns $\frac{1}{2}(2 N-3+1)=N-1$ of them tails by alternately flipping them. Hobbes never gets to make a move to stop this sequence, so Calvin wins.


problem:
Euler marks $n$ different points in the Euclidean plane. For each pair of marked points, Gauss writes down the number $\left\lfloor\log _{2} d\right\rfloor$ where $d$ is the distance between the two points. Prove that Gauss writes down less than $2 n$ distinct values.

Note: For any $d>0,\left\lfloor\log _{2} d\right\rfloor$ is the unique integer $k$ such that $2^{k} \leq d<2^{k+1}$.

solution:
We first prove that the Gauss writes down at most $n$ even numbers.

For each even number $2 k$ that Gauss writes down, choose a single pair of points whose distance $d$ satisfies $2^{2 k} \leq d<2^{2 k+1}$. Connect these points with a red edge. We claim there cannot be a cycle $\{$ of length $m, 3 \leq m \leq n\}$ : indeed, if the edges corresponding to the distinct even integers $2 k_{1}, \ldots, 2 k_{m}, 2 k_{m+1}$ form a cycle in that order, then assume without loss of generality that $2 k_{m+1}$ is the largest among these, and $2 k_{i}$ is the largest among the rest. The sum of distances for the first $m$ edges is at most

$$
2^{2 k_{1}+1}+\cdots+2^{2 k_{m}+1} \leq 2^{2 k_{i}+1}\left(1+2^{-2}+2^{-4}+\cdots\right) \leq \frac{2^{2 k_{i}+1}}{1-\frac{1}{2^{2}}}<2^{2 k_{i}+2} \leq 2^{2 k_{m+1}}
$$

i.e., less than the distance corresponding to the last edge: a contradiction to triangle inequality. So there are at most $n-1$ red edges.

This implies that Gauss only writes at most $n-1$ even numbers, and similarly at most $n-1$ odd numbers. Thus, Gauss writes down at most $2 n-2$ numbers in total.

problem_match: Problem 5.


solution:
Given a pair of points with distance $d$, we say their log-distance is $\left\lfloor\log _{2} d\right\rfloor$. By dilating by a suitable power of 2 , we can assume all log-distances are positive and the smallest one of them is 1 . Define a sequence of graphs $G_{0}, G_{1}, G_{2}, \cdots$ as follows: $G_{k}$ has the $n$ points as vertices, and two points are joined by an edge in it if and only if their log-distance is at most $k$. In particular, $G_{0}$ is a graph with $n$ vertices and no edges.

Now we define a second sequence of graphs $H_{0}, H_{1}, H_{2}, \cdots$ with $H_{i}$ being a subgraph of $G_{i}$ inductively as follows. We let $H_{0}$ be the same as $G_{0}$ and $H_{1}$ by adding an edge with log-distance 1. Now once we have defined $H_{k-1}, H_{k}$ is obtained from it as follows:

- If $H_{k-1}$ is a disjoint union of cliques, choose a pair of points with log-distance $k$, and add the edge between them to $H_{k-1}$ to form $H_{k}$ : such an index $k$ will be called clique-destroyer. If no such pair exists, let $H_{k}=H_{k-1}$ : in this case, the index $k$ will be called empty.
- If not, then $H_{k-1}$ was obtained by adding one edge between cliques $C_{1}$ and $C_{2}$ in $H_{k-2} \subseteq G_{k-2}$. We claim that all edges between $C_{1}$ and $C_{2}$ are in $G_{k}$. Indeed, if suppose the edge was added between points $A_{1} \in C_{1}$ and $A_{2} \in C_{2}$. Take any point $B_{1} \in C_{1}$ and $B_{2} \in C_{2}$. By assumption, $B_{1} A_{1}$ and $B_{2} A_{2}$ are edges in $G_{k-2}$ and $A_{1} A_{2}$ is an edge in $G_{k-1}$, so $\left|B_{1} A_{1}\right|<2^{k-1},\left|B_{2} A_{2}\right|<2^{k-1}$, and $\left|A_{1} A_{2}\right|<2^{k}$, so by triangle inequality,

$$
\left|B_{1} B_{2}\right|<2^{k-1}+2^{k-1}+2^{k}=2^{k+1}
$$

which proves our claim. Now to form $H_{k}$, we take $H_{k-1}$ and add all edges between $C_{1}$ and $C_{2}$ : this yields a disjoint union of cliques. This index $k$ will be called cliquerestorer.

Now for every clique-destroyer index $k$, either $H_{k}$ is again a disjoint union of cliques with one fewer clique than $H_{k-1}$, or it is followed by a clique-restorer index $k+1$ (as we add all the missing edges between some two disjoint cliques $C_{1}$ and $C_{2}$ connected by an edge), and $H_{k+1}$ is a disjoint union of cliques with one fewer clique than $H_{k-1}$. Initially, $H_{0}$ has $n$ cliques and the chain stops once $H_{k}$ becomes a single clique on $n$ vertices. There can be at most $2(n-1)$ indices that are one of the above two types. However, the empty indices correspond to values of $k$ that do not occur as a log-distance: therefore the number of distinct values of log-distance is at most the number of non-empty indices, i.e., at most $2 n-2$ as desired.


problem:
Euclid has a tool called cyclos which allows him to do the following:

- Given three non-collinear marked points, draw the circle passing through them.
- Given two marked points, draw the circle with them as endpoints of a diameter.
- Mark any intersection points of two drawn circles or mark a new point on a drawn circle.

Show that given two marked points, Euclid can draw a circle centered at one of them and passing through the other, using only the cyclos.

solution:
We begin by proving a series of lemmas.

Lemma 1. Given a non-right angled triangle $A B C$, we can draw the nine-point circle and mark the orthocentre $H$ using only a cyclos.

Proof. Draw circles $(B C),(C A),(A B)$ and mark their intersections to get the three feet of altitudes $D, E, F$ opposite $A, B, C$. Now draw the circle $(D E F)$ to get the nine-point circle. Draw $(B D F),(C D E),(A E F)$ and they meet at $H$, which we can also mark.

Lemma 2. Given points $A, B$, we can mark the midpoint $M$ of $A B$ using only a cyclos.

Proof. Draw the circle $(A B)$ and choose a point $X$ on it. Draw circles $(X A),(X B)$ and mark their intersection $Y$. Now mark a point $Z$ on the circle $(X A)$ apart from the marked points. Clearly, $Z$ does not lie on $A B$ nor on $(A B)$, hence we can draw $(A Z B)$. Mark five points $Z_{1}, \ldots, Z_{5}$ on this circle, each different from all previous points and verify if either $A$ lies on $\left(Z_{i} B\right)$ or $B$ lies on $\left(Z_{i} A\right)$ for each $1 \leq i \leq 5$ before marking the new point. By pigeonhole principle, for some three indices $i, j, k$, the three triangles $A Z_{i} B$ are non-right angled, hence we can draw their ninepoint circles by Lemma 1. All of them pass through $M$, and their centres are not collinear, else homothety at the centre of $(A B Z)$ implies the orthocentres of the three triangles are collinear; but they all lie on the reflection of $(A Z B)$ in $A B$, a contradiction! Thus, these three nine-point circles meet at only $M$, and we mark this point.

Lemma 3. Given points $A, B, C, D$ on the plane in general position, we can mark the intersection point $E$ of lines $A B$ and $C D$ using only a cyclos.

Proof. Draw $(A B)$ and mark five points on it, all different from previously marked points. For each marked point $X$; draw $(C X)$ and $(D X)$ and check whether they have an intersection apart from $X$ (i.e., if they are tangent, or if $X$ lies on $C D$ ). We can find three points $X_{1}, X_{2}, X_{3}$ among them not lying on $C D$. Denote by $Y_{i}$ the second intersection of $\left(A X_{i}\right),\left(B X_{i}\right)$ and by $Z_{i}$ the second intersection of $\left(C X_{i}\right),\left(D X_{i}\right)$ and mark them, for each $1 \leq i \leq 3$. Draw the circles $\left(X_{i} Y_{i} Z_{i}\right)$ and note that they all pass through $E$ and have diameters $E X_{i}$ for all $i$; so they are not coaxial as $X_{1}, X_{2}, X_{3}$ are not collinear; all lying on $(A B)$. Thus we mark $E$ as the unique point common to them all. (Note: if $C, D$ lie on $(A B)$, we can pick a point $T$ on it other than these four, then a point $X$ on $(A T)$, and continue the same argument again, avoiding all edge cases.)

Lemma 4. Given a circle $\Gamma$, we can mark the centre of $\Gamma$ using only a cyclos.

Proof. Mark points $A, B, C \in \Gamma$ and mark the midpoints of $B C, C A, A B$ to get $A_{1}, B_{1}, C_{1}$ according to Lemma 2. Draw the circles $\left(A B_{1} C_{1}\right),\left(B A_{1} C_{1}\right),\left(C B_{1} A_{1}\right)$ and mark the intersection to get the centre of $\Gamma$.

Lemma 5. Given a circle $\Gamma$ and point $A$ on $\Gamma$, we can mark a point $K$ such that line $A K$ is tangent to $\Gamma$ using only a cyclos.

Proof. Mark points $B_{1}, B_{2}, B_{3}$ and $C$ on $\Gamma$. By Lemma 4, mark the point $O$, the centre of $\Gamma$. Draw $\left(B_{i} O\right)$ and $(A O C)$ and mark the intersection denoted $F_{i}$; there exists an index $j$ for which $F_{j} \neq O$; mark the point $K$ which is the intersection of $B_{j} F_{j}$ and $O M$ where $M$ is the midpoint of $A C$ (which we mark by Lemma 2) by Lemma 3. Clearly, $K$ lies on $A$ tangent to $\Gamma$. Note that we can do this again to get multiple such points $K$ by choosing different $C$ each time.

Lemma 6. Given a circle $\Gamma$ and a point $A$ on $\Gamma$, and a point $B$ not on $\Gamma$, we can mark the point $C$ which is the second intersection of line $A B$ and $\Gamma$ using only a cyclos.

Proof. Mark the foot of perpendicular $M$ from $O$ onto line $A B$ as done in Lemma 1. Mark the intersection of line $O M$ and $A K$ by Lemma 3 , where $K$ is a point on the $A$-tangent to $\Gamma$ as constructed in Lemma 5. Draw $(O A K)$ and mark the second intersection with $\Gamma$ to obtain $C$.

Lemma 7. Given points $A, B, C$ not all on a line, we can draw the reflection of $A$ in $B C$ using only a cyclos.

Proof. Draw $(A B C)$ and mark the orthocentre $H$ of $A B C$ by Lemma 1. Mark the intersection $A^{\prime}$ of line $A H$ with $(B H C)$ using Lemma 6 , which is the $A$-reflection in line $B C$.

Lemma 8. Given points $A, B$, we can mark the point $C$ which is the reflection of $A$ in $B$ using only a cyclos.

Proof. Draw $(A B)$, and by Lemma 6, mark two points $K_{1}, K_{2}$ such that $B K_{i}$ is tangent to $(A B)$ for $i \in\{1,2\}$. By Lemma 7 , mark the reflection $C$ of $A$ in line $K_{1} K_{2}$ as desired.

Thus, a cyclos can do everything a compass can: to draw a circle with given centre $A$ and given radius $B$, we use Lemma 8 to mark the reflection $C$ of $B$ in $A$ and use the cyclos to draw $(B C)$ which has centre $A$ and passes through $B$.

problem_match: Problem 6.


solution:
After deriving the first two lemmas in the previous solution, one can proceed as follows: Let $C$ denote the point such that $A$ is the midpoint of $C B$.

Choose a generic point $X$. We can get the midpoint $M$ of $B X$ and the foot of perpendicular $D$ from $X$ to $A B$. Draw the circle passing through $A, D$ and $M$. This is the nine-point of circle of triangle $C B X$. Intersect this circle with the circle whose diameter is $B X$. The intersection point other than $D$ is the foot of perpendicular $E$ from $B$ to $C X$. Note that $|A E|=|A B|$. Similarly, we can construct another point $F$ such that $|A F|=|A B|$. The circle through $B, E$ and $F$ is the required circle.