exam: BalticWay

problem: For $n \geq 2$, an equilateral triangle is divided into $n^{2}$ congruent smaller equilateral triangles. Determine all ways in which real numbers can be assigned to the $\frac{(n+1)(n+2)}{2}$ vertices so that three such numbers sum to zero whenever the three vertices form a triangle with edges parallel to the sides of the big triangle.

solution:
We label the vertices (and the corresponding real numbers) as follows.
![](https://cdn.mathpix.com/cropped/2024_04_17_d4daccd4c48173d57f8eg-01.jpg?height=350&width=482&top_left_y=1136&top_left_x=819)

For $n=2$, we see that

$$
a_{2}+a_{4}+a_{5}=0=a_{2}+a_{3}+a_{5}
$$

which shows that $a_{3}=a_{4}$ and similarly $a_{1}=a_{5}$ and $a_{2}=a_{6}$. Now the only additional requirement is $a_{1}+a_{2}+a_{3}=0$, so that all solutions are of the following form, for any $x, y$ and $z$ with $x+y+z=0$ :
![](https://cdn.mathpix.com/cropped/2024_04_17_d4daccd4c48173d57f8eg-01.jpg?height=256&width=452&top_left_y=1716&top_left_x=838)

For $n=3$, observe that $a_{1}=a_{7}=a_{10}$ since they all equal $a_{5}$. Since also $a_{1}+a_{7}+a_{10}=0$, they all equal zero. By considering the top triangle, we get $x=a_{2}=-a_{3}$ and this uniquely determines the rest. It is easily checked that, for any real $x$, this is actually a solution:
![](https://cdn.mathpix.com/cropped/2024_04_17_d4daccd4c48173d57f8eg-02.jpg?height=292&width=112&top_left_y=373&top_left_x=1104)

For $n \geq 3$ we can apply the same argument as above for any collection of 10 vertices. Any vertex not on the sides of the big triangle has to equal zero, since it is the centre of such a collection of 10 vertices. Any vertex $a$ on the sides of the big triangle forms some parallelogram similar to $a_{4}, a_{2}, a_{5}, a_{8}$, where the point opposite $a$ is in the interior of the big triangle. Since such opposite numbers are equal, all $a_{i}$ have to be zero in this case.

problem_match: # Problem 1.

solution_match: Solution.


problem:
Let $n$ be a positive integer and let $a_{1}, \ldots, a_{n}$ be real numbers satisfying $0 \leq a_{i} \leq 1$ for $i=1, \ldots, n$. Prove the inequality

$$
\left(1-a_{1}^{n}\right)\left(1-a_{2}^{n}\right) \cdots\left(1-a_{n}^{n}\right) \leq\left(1-a_{1} a_{2} \cdots a_{n}\right)^{n} .
$$

solution:
The numbers $1-a_{i}^{n}$ are positive by assumption. AM-GM gives

$$
\begin{aligned}
\left(1-a_{1}^{n}\right)\left(1-a_{2}^{n}\right) \cdots\left(1-a_{n}^{n}\right) & \leq\left(\frac{\left(1-a_{1}^{n}\right)+\left(1-a_{2}^{n}\right)+\cdots+\left(1-a_{n}^{n}\right)}{n}\right)^{n} \\
& =\left(1-\frac{a_{1}^{n}+\cdots+a_{n}^{n}}{n}\right)^{n} .
\end{aligned}
$$

By applying AM-GM again we obtain

$$
a_{1} a_{2} \cdots a_{n} \leq \frac{a_{1}^{n}+\cdots+a_{n}^{n}}{n} \Rightarrow\left(1-\frac{a_{1}^{n}+\cdots+a_{n}^{n}}{n}\right)^{n} \leq\left(1-a_{1} a_{2} \cdots a_{n}\right)^{n}
$$

and hence the desired inequality.

Remark. It is possible to use Jensen's inequality applied to $f(x)=\log \left(1-e^{x}\right)$.

problem_match: # Problem 2.


problem:
Let $n>1$ be an integer. Find all non-constant real polynomials $P(x)$ satisfying, for any real $x$, the identity

$$
P(x) P\left(x^{2}\right) P\left(x^{3}\right) \cdots P\left(x^{n}\right)=P\left(x^{\frac{n(n+1)}{2}}\right) .
$$

solution:
Answer: $P(x)=x^{m}$ if $n$ is even; $P(x)= \pm x^{m}$ if $n$ is odd.

Consider first the case of a monomial $P(x)=a x^{m}$ with $a \neq 0$. Then

$$
a x^{\frac{m n(n+1)}{2}}=P\left(x^{\frac{n(n+1)}{2}}\right)=P(x) P\left(x^{2}\right) P\left(x^{3}\right) \cdots P\left(x^{n}\right)=a x^{m} \cdot a x^{2 m} \cdots a x^{n m}=a^{n} x^{\frac{m n(n+1)}{2}}
$$

implies $a^{n}=a$. Thus, $a=1$ when $n$ is even and $a= \pm 1$ when $n$ is odd. Obviously these polynomials satisfy the desired equality.

Suppose now that $P$ is not a monomial. Write $P(x)=a x^{m}+Q(x)$, where $Q$ is non-zero polynomial with $\operatorname{deg} Q=k<m$. We have

$$
\begin{aligned}
a x^{\frac{m n(n+1)}{2}}+Q & \left(x^{\frac{n(n+1)}{2}}\right)=P\left(x^{\frac{n(n+1)}{2}}\right) \\
& =P(x) P\left(x^{2}\right) P\left(x^{3}\right) \cdots P\left(x^{n}\right)=\left(a x^{m}+Q(x)\right)\left(a x^{2 m}+Q\left(x^{2}\right)\right) \cdots\left(a x^{n m}+Q\left(x^{n}\right)\right) .
\end{aligned}
$$

The highest degree of a monomial, on both sides of the equality, is $\frac{m n(n+1)}{2}$. The second highest degree in the right-hand side is

$$
2 m+3 m+\cdots+n m+k=\frac{m(n+2)(n-1)}{2}+k
$$

while in the left-hand side it is $\frac{k n(n+1)}{2}$. Thus

$$
\frac{m(n+2)(n-1)}{2}+k=\frac{k n(n+1)}{2}
$$

which leads to

$$
(m-k)(n+2)(n-1)=0
$$

and so $m=k$, contradicting the assumption that $m>k$. Consequently, no polynomial of the form $a x^{m}+Q(x)$ fulfils the given condition.

problem_match: # Problem 3.


problem: A family wears clothes of three colours: red, blue and green, with a separate, identical laundry bin for each colour. At the beginning of the first week, all bins are empty. Each week, the family generates a total of $10 \mathrm{~kg}$ of laundry (the proportion of each colour is subject to variation). The laundry is sorted by colour and placed in the bins. Next, the heaviest bin (only one of them, if there are several that are heaviest) is emptied and its contents washed. What is the minimal possible storing capacity required of the laundry bins in order for them never to overflow?

solution:
Answer: $25 \mathrm{~kg}$.

Each week, the accumulation of laundry increases the total amount by $K=10$, after which the washing decreases it by at least one third, because, by the pigeon-hole principle, the bin with the most laundry must contain at least a third of the total. Hence the amount of laundry post-wash after the $n$th week is bounded above by the sequence $a_{n+1}=\frac{2}{3}\left(a_{n}+K\right)$ with $a_{0}=0$, which is clearly bounded above by $2 K$. The total amount of laundry is less than $2 K$ post-wash and $3 K$ pre-wash.

Now suppose pre-wash state $(a, b, c)$ precedes post-wash state $(a, b, 0)$, which precedes pre-wash state $\left(a^{\prime}, b^{\prime}, c^{\prime}\right)$. The relations $a \leq c$ and $a^{\prime} \leq a+K$ lead to

$$
3 K>a+b+c \geq 2 a \geq 2\left(a^{\prime}-K\right)
$$

and similarly for $b^{\prime}$, whence $a^{\prime}, b^{\prime}<\frac{5}{2} K$. Since also $c^{\prime} \leq K$, a pre-wash bin, and a fortiori a post-wash bin, always contains less than $\frac{5}{2} K$.

Consider now the following scenario. For a start, we keep packing the three bins equally full before washing. Initialising at $(0,0,0)$, the first week will end at $\left(\frac{1}{3} K, \frac{1}{3} K, \frac{1}{3} K\right)$ pre-wash and $\left(\frac{1}{3} K, \frac{1}{3} K, 0\right)$ post-wash, the second week at $\left(\frac{5}{9} K, \frac{5}{9} K, \frac{5}{9} K\right)$ pre-wash and $\left(\frac{5}{9} K, \frac{5}{9} K, 0\right)$ post-wash, \&c. Following this scheme, we can get arbitrarily close to the state $(K, K, 0)$ after washing. Supposing this accomplished, placing $\frac{1}{2} K \mathrm{~kg}$ of laundry in each of the non-empty bins leaves us in a state close to $\left(\frac{3}{2} K, \frac{3}{2} K, 0\right)$ pre-wash and $\left(\frac{3}{2} K, 0,0\right)$ post-wash. Finally, the next week's worth of laundry is directed solely to the single non-empty bin. It may thus contain any amount of laundry below $\frac{5}{2} K \mathrm{~kg}$.

problem_match: # Problem 4.

solution_match: # Solution.


problem:
Find all functions $f: \mathbf{R} \rightarrow \mathbf{R}$ satisfying the equation

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

for all real numbers $x$ and $y$.

solution:
Answer: all functions $f(x)=c(|x|-x)$, where $c \geq 0$.

Choosing $x=y=0$, we find

$$
f(f(0))=-2 f(0)
$$

Denote $a=f(0)$, so that $f(a)=-2 a$, and choose $y=0$ in the initial equation:

$$
a|x|=a+f\left(x^{2}\right)+f(a)=a+f\left(x^{2}\right)-2 a \quad \Rightarrow \quad f\left(x^{2}\right)=a(|x|+1)
$$

In particular, $f(1)=2 a$. Choose $(x, y)=\left(z^{2}, 1\right)$ in the initial equation:

$$
\begin{aligned}
& z^{2} f(1)+f\left(z^{2}\right)=f\left(z^{2}\right)+f\left(z^{4}\right)+f(f(1)) \\
\Rightarrow & 2 a z^{2}=z^{2} f(1)=f\left(z^{4}\right)+f(f(1))=a\left(z^{2}+1\right)+f(2 a) \\
\Rightarrow & a z^{2}=a+f(2 a)
\end{aligned}
$$

The right-hand side is constant, while the left-hand side is a quadratic function in $z$, which can only happen if $a=0$. (Choose $z=1$ and then $z=0$.)

We now conclude that $f\left(x^{2}\right)=0$, and so $f(x)=0$ for all non-negative $x$. In particular, $f(0)=0$. Choosing $x=0$ in the initial equation, we find $f(f(y))=0$ for all $y$. Simplifying the original equation and swapping $x$ and $y$ leads to

$$
|x| f(y)+y f(x)=f(x y)=|y| f(x)+x f(y) .
$$

Choose $y=-1$ and put $c=\frac{f(-1)}{2}$ :

$$
|x| f(-1)-f(x)=f(x)+x f(-1) \Rightarrow f(x)=\frac{f(-1)}{2}(|x|-x)=c(|x|-x) \text {. }
$$

One easily verifies that these functions satisfy the functional equation for any parameter $c \geq 0$.

problem_match: # Problem 5.


problem: Two players take alternate turns in the following game. At the outset there are two piles, containing 10,000 and 20,000 tokens, respectively. A move consists of removing any positive number of tokens from a single pile or removing $x>0$ tokens from one pile and $y>0$ tokens from the other, where $x+y$ is divisible by 2015. The player who cannot make a move loses. Which player has a winning strategy?

solution:
The first player wins.

He should present his opponent with one of the following positions:

$$
(0,0), \quad(1,1), \quad(2,2), \quad \ldots, \quad(2014,2014) .
$$

All these positions have different total numbers of tokens modulo 2015. Therefore, if the game starts from two piles of arbitrary sizes, it is possible to obtain one of these positions just by the first move. In our case

$$
10,000+20,000 \equiv 1790 \bmod 2015,
$$

and the first player can leave to his opponent the position $(895,895)$.

Now the second type of move can no longer be carried out. If the second player removes $n$ tokens from one pile, the first player may always respond be removing $n$ tokens from the other pile.

problem_match: # Problem 6.


problem: There are 100 members in a ladies' club. Each lady has had tea (in private) with exactly 56 of the other members of the club. The Board, consisting of the 50 most distinguished ladies, have all had tea with one another. Prove that the entire club may be split into two groups in such a way that, within each group, any lady has had tea with any other.

solution: Each lady in the Board has had tea with 49 ladies within the Board, and 7 ladies without. Each lady not in the Board has had tea with at most 49 ladies not in the Board, and at least 7 ladies in the Board. Comparing these two observations, we conclude that each lady not in the Board has had tea with exactly 49 ladies not in the Board and exactly 7 ladies in the Board. Hence the club may be split into Board members and non-members.

problem_match: # Problem 7.


problem:
With inspiration drawn from the rectilinear network of streets in New York, the Manhattan distance between two points $(a, b)$ and $(c, d)$ in the plane is defined to be

$$
|a-c|+|b-d| \text {. }
$$

Suppose only two distinct Manhattan distances occur between all pairs of distinct points of some point set. What is the maximal number of points in such a set?

solution:
Answer: nine.

Let

$$
\left\{\left(x_{1}, y_{1}\right), \ldots,\left(x_{m}, y_{m}\right)\right\}, \quad \text { where } \quad x_{1} \leq \cdots \leq x_{m}
$$

be the set, and suppose $m \geq 10$.

A special case of the Erdős-Szekeres Theorem asserts that a real sequence of length $n^{2}+1$ contains a monotonic subsequence of length $n+1$. (Proof: Given a sequence $a_{1} \ldots, a_{n^{2}+1}$, let $p_{i}$ denote the length of the longest increasing subsequence ending with $a_{i}$, and $q_{i}$ the length of the longest decreasing subsequence ending with $a_{i}$. If $i<j$ and $a_{i} \leq a_{j}$, then $p_{i}<p_{j}$. If $a_{i} \geq a_{j}$, then $q_{i}<q_{j}$. Hence all $n^{2}+1$ pairs $\left(p_{i}, q_{i}\right)$ are distinct. If all of them were to satisfy $1 \leq p_{i}, q_{i} \leq n$, it would violate the Pigeon-Hole Principle.)

Applied to the sequence $y_{1}, \ldots, y_{m}$, this will produce a subsequence

$$
y_{i} \leq y_{j} \leq y_{k} \leq y_{l} \quad \text { or } \quad y_{i} \geq y_{j} \geq y_{k} \geq y_{l}
$$

One of the shortest paths from $\left(x_{i}, y_{i}\right)$ to $\left(x_{l}, y_{l}\right)$ will pass through first $\left(x_{j}, y_{j}\right)$ and then $\left(x_{k}, y_{k}\right)$. At least three distinct Manhattan distances will occur.

Conversely, among the nine points

$$
(0,0), \quad( \pm 1, \pm 1), \quad( \pm 2,0), \quad(0, \pm 2),
$$

only the Manhattan distances 2 and 4 occur.

problem_match: # Problem 8.


problem:
Let $n>2$ be an integer. A deck contains $\frac{n(n-1)}{2}$ cards, numbered

$$
1,2,3, \ldots, \frac{n(n-1)}{2}
$$

Two cards form a magic pair if their numbers are consecutive, or if their numbers are 1 and $\frac{n(n-1)}{2}$.

For which $n$ is it possible to distribute the cards into $n$ stacks in such a manner that, among the cards in any two stacks, there is exactly one magic pair?

solution:
. Answer: for all odd $n$.

First assume a stack contains two cards that form a magic pair; say cards number $i$ and $i+1$. Among the cards in this stack and the stack with card number $i+2$ (they might be identical), there are two magic pairs - a contradiction. Hence no stack contains a magic pair.

Each card forms a magic pair with exactly two other cards. Hence if $n$ is even, each stack must contain at least $\left\lceil\frac{n-1}{2}\right\rceil=\frac{n}{2}$ cards, since there are $n-1$ other stacks. But then we need at least $n \frac{n}{2}>\frac{n(n-1)}{2}$ cards - a contradiction.

In the odd case we distribute the cards like this: Let $a_{1}, a_{2}, \ldots, a_{n}$ be the $n$ stacks and let $n=2 m+1$. Card number 1 is put into stack $a_{1}$. If card number $k m+i$, for $i=1,2, \ldots, m$, is put into stack $a_{j}$, then card number $k m+i+1$ is put into stack number $a_{j+i}$, where the indices are calculated modulo $n$.

There are

$$
\frac{n(n-1)}{2}=\frac{(2 m+1)(2 m)}{2}=m(2 m+1)
$$

cards. If we look at all the card numbers of the form $k m+1$, there are exactly $n=2 m+1$ of these, and we claim that there is exactly one in each stack. Card number 1 is in stack $a_{1}$, and card number $k m+1$ is in stack

$$
a_{1+k(1+2+3+\cdots+m)}
$$

Since

$$
1+2+3+\cdots+m=\frac{m(m+1)}{2}
$$

and $\operatorname{gcd}\left(2 m+1, \frac{m(m+1)}{2}\right)=1$, all the indices

$$
1+k(1+2+3+\cdots+m), \quad k=0,1,2, \ldots, 2 m
$$

are different modulo $n=2 m+1$. In the same way we see that each stack contains exactly one of the $2 m+1$ cards with the numbers $k m+i$ for a given $i=2,3, \ldots, m$.

Now look at two different stacks $a_{v}$ and $a_{u}$. Then, without loss of generality, we may assume that $u=v+i$ for some $i=1,2, \ldots, m$ (again we consider the index modulo $n=2 m+1$ ). Since there is a card in stack $a_{v}$ with number $k m+i$, the card $k m+i+1$ is in stack $a_{v+i}=a_{u}$. Hence among the cards in any two stacks there is at least one magic pair. Since there is the same number of pairs of stacks as of magic pairs, there must be exactly one magic pair among the cards of any two stacks.

problem_match: # Problem 9.

solution_match: # Solution 1


solution: (found by Saint Petersburg). For the case of $n$ odd, consider the complete graph on the vertices $1, \ldots, n$ with $\frac{n(n-1)}{2}$ edges. The degree of each vertex is $n-1$, which is even, hence an Euler cycle $v_{1} v_{2} \cdots v_{\frac{n(n-1)}{2}} v_{1}$ exists. Place card number $i$ into stack number $v_{i}$. The magic pairs correspond to edges in the cycle.

solution_match: Solution 2


problem:
A subset $S$ of $\{1,2, \ldots, n\}$ is called balanced if for every $a \in S$ there exists some $b \in S, b \neq a$, such that $\frac{a+b}{2} \in S$ as well.

(a) Let $k>1$ be an integer and let $n=2^{k}$. Show that every subset $S$ of $\{1,2, \ldots, n\}$ with $|S|>\frac{3 n}{4}$ is balanced.

(b) Does there exist an $n=2^{k}$, with $k>1$ an integer, for which every subset $S$ of $\{1,2, \ldots, n\}$ with $|S|>\frac{2 n}{3}$ is balanced?

Solution of part (a). Let $m=n-|S|$, thus $m<\frac{n}{4}$ and (as $n$ is a multiple of 4 ) $m \leq \frac{n}{4}-1$. Let $a \in S$. There are $\frac{n}{2}-1$ elements in $\{1,2, \ldots, n\}$ distinct from $a$ and with the same parity as $a$. At most $m$ of those elements are not in $S$, hence at least $\frac{n}{2}-1-m \geq \frac{n}{4}$ of them are in $S$. For each such $b$, the number $\frac{a+b}{2}$ is an integer, and all of these at least $\frac{n}{4}$ numbers are distinct. But at most $m<\frac{n}{4}$ of them are not in $S$, so at least one is a member of $S$. Hence $S$ is balanced.

solution:
of part (b). For convenience we work with $\{0,1, \ldots, n-1\}$ rather than $\{1,2, \ldots, n\}$; this does not change the problem. We show that one can always find an unbalanced subset containing more than $\frac{2 n}{3}$ elements.

Let $\operatorname{ord}_{2}(i)$ denote the number of factors 2 occurring in the prime factorisation of $i$. We set

$$
T_{j}=\left\{i \in\{1,2, \ldots, n-1\} \mid \operatorname{ord}_{2}(i)=j\right\}
$$

Then we choose

$$
S=\{0,1,2, \ldots, n-1\} \backslash\left(T_{1} \cup T_{3} \cup \cdots \cup T_{l}\right), \quad \text { where } l= \begin{cases}k-1 & \text { if } k \text { even } \\ k-2 & \text { if } k \text { odd. }\end{cases}
$$

Observe that $\left|T_{j}\right|=\frac{n}{2^{j+1}}$, so

$$
|S|=n-\left(\frac{n}{4}+\frac{n}{16}+\cdots+\frac{n}{2^{l+1}}\right)=n-n \cdot \frac{\frac{1}{4}-\frac{1}{2^{l+3}}}{1-\frac{1}{4}}>n-\frac{n}{3}=\frac{2 n}{3} .
$$

We show that $S$ is not balanced. Take $a=0 \in S$, and consider a $0 \neq b \in S$. If $b$ is odd, then $\frac{0+b}{2}$ is not integral. If $b$ is even, then $b \in T_{2} \cup T_{4} \cup \cdots$, so $\frac{b}{2} \in T_{1} \cup T_{3} \cup \cdots$, hence $\frac{b}{2} \notin S$. Thus $S$ is not balanced.

problem_match: # Problem 10.

solution_match: Solution 1


solution:
of part (b). We define the sets

$$
A_{j}=\left\{2^{j-1}+1,2^{j-1}+2, \ldots, 2^{j}\right\}
$$

and set

$$
S=A_{k} \cup A_{k-2} \cup \cdots \cup A_{l} \cup\{1\}, \quad \text { where } l= \begin{cases}2 & \text { if } k \text { even }, \\ 1 & \text { if } k \text { odd. }\end{cases}
$$

Note that $A_{j} \subseteq\{1,2, \ldots, n\}$ whenever $j \leq k$, and that $\left|A_{j}\right|=2^{j-1}$. We find

$$
|S|=2^{k-1}+2^{k-3}+\cdots+2^{l-1}+1=\frac{2^{l-1}-2^{k+1}}{1-4}+1=-\frac{2^{l-1}}{3}+\frac{2 n}{3}+1>\frac{2 n}{3} .
$$

We show that $S$ is not balanced. Take $a=1 \in S$, and consider a $1 \neq b \in S$. Then $b \in A_{j}$ for some $j$. If $b$ is even, then $\frac{1+b}{2}$ is not integral. If $b$ is odd, then also $1+b \in A_{j}$, so $\frac{1+b}{2} \in A_{j-1}$ and does not lie in $S$. Thus $S$ is not balanced.


solution:
of part (b). Let us introduce the concept of lonely element as an $a \in S$ for which there does not exist a $b \in S$, distinct from $a$, such that $\frac{a+b}{2} \in S$.

We will construct an unbalanced set $S$ with $|S|>\frac{2 n}{3}$ for all $k$. For $n=4$ we can use $S=\{1,2,4\}$ (all elements are lonely), and for $n=8$ we can use $S=\{1,2,3,5,6,7\}$ (2 and 6 are lonely).

We now construct an unbalanced set $S \subseteq\{1,2, \ldots, 4 n\}$, given an unbalanced set $T \subseteq\{1,2, \ldots, n\}$ with $|T|>\frac{2 n}{3}$. Take

$$
S=\{i \in\{1,2, \ldots, 4 n\} \mid i \equiv 1 \bmod 2\} \cup\{4 t-2 \mid t \in T\}
$$

Then

$$
|S|=2 n+|T|>2 n+\frac{2 n}{3}=\frac{8 n}{3}=\frac{2 \cdot 4 n}{3} .
$$

![](https://cdn.mathpix.com/cropped/2024_04_17_d4daccd4c48173d57f8eg-08.jpg?height=393&width=393&top_left_y=291&top_left_x=866)

Figure 1: Problem 11.

Supposing $a \in T$ is lonely, we will show that $4 a-2 \in S$ is lonely. Indeed, suppose $4 a-2 \neq b \in S$ with

$$
\frac{4 a-2+b}{2}=2 a-1+\frac{b}{2} \in S .
$$

Then $b$ must be even, so $b=4 t-2$ for some $a \neq t \in T$. But then

$$
\frac{4 a-2+4 t-2}{2}=4 \frac{a+t}{2}-2
$$

again an even element. However, as $a$ is lonely we know that $\frac{a+t}{2} \notin T$, and hence $4 \frac{a+t}{2}-2 \notin S$. We conclude that $4 a-2$ is lonely in $S$.

Thus $S$ is an unbalanced set, and by induction we can find an unbalanced set of size exceeding $\frac{2 n}{3}$ for all $k>1$.

solution_match: Solution 3


problem: The diagonals of the parallelogram $A B C D$ intersect at $E$. The bisectors of $\angle D A E$ and $\angle E B C$ intersect at $F$. Assume that $E C F D$ is a parallelogram. Determine the ratio $A B: A D$.

solution: Since $E C F D$ is a parallelogram, we have $E D \| C F$ and $\angle C F B=\angle E B F=\angle F B C(B F$ bisects $\angle D B C$ ). So $C F B$ is an isosceles triangle and $B C=C F=E D$ (ECFD is a parallelogram). In a similar manner, $E C=A D$. But since $A B C D$ is a parallelogram, $A D=B C$, whence $E C=E D$. So the diagonals of $A B C D$ are equal, which means that $A B C D$ is in fact a rectangle. Also, the triangles $E D A$ and $E B C$ are equilateral, and so $A B$ is twice the altitude of $E D A$, or $A B=\sqrt{3} \cdot A D$.

problem_match: # Problem 11.


problem: A circle passes through vertex $B$ of the triangle $A B C$, intersects its sides $A B$ and $B C$ at points $K$ and $L$, respectively, and touches the side $A C$ at its midpoint $M$. The point $N$ on the $\operatorname{arc} B L$ (which does not contain $K)$ is such that $\angle L K N=\angle A C B$. Find $\angle B A C$ given that the triangle $C K N$ is equilateral.

solution:
Answer: $\angle B A C=75^{\circ}$.

Since $\angle A C B=\angle L K N=\angle L B N$, the lines $A C$ and $B N$ are parallel. Hence $A C N B$ is a trapezium. Moreover, $A C N B$ is an isosceles trapezium, because the segment $A C$ touches the circle $s$ in the midpoint (and so the trapezium is symmetrical with respect to the perpendicular bisectors of $B N$ ).
![](https://cdn.mathpix.com/cropped/2024_04_17_d4daccd4c48173d57f8eg-09.jpg?height=434&width=912&top_left_y=282&top_left_x=602)

Figure 2: Problem 12.

Denote by $K^{\prime}$ the intersection point of $s$ and $C N$. Then the line $K K^{\prime}$ is parallel to the bases of the trapezium. Hence $M$ is the midpoint of $\operatorname{arc} K K^{\prime}$ and the line $N M$ is an angle bisector of the equilateral triangle $K N C$.

Thus we obtain that $M C=M K$. Therefore the length of median $K M$ of the triangle $A K C$ equals $\frac{1}{2} A C$; hence $\angle A K C=90^{\circ}$. We have

$$
2 \angle A=\angle K A C+\angle A C N=\angle K A C+\angle A C K+\angle K C N=90^{\circ}+60^{\circ}=150^{\circ} \text {, }
$$

and so $\angle A=75^{\circ}$.

problem_match: # Problem 12.


problem: Let $D$ be the footpoint of the altitude from $B$ in the triangle $A B C$, where $A B=1$. The incentre of triangle $B C D$ coincides with the centroid of triangle $A B C$. Find the lengths of $A C$ and $B C$.

solution:
Answer: $A C=B C=\sqrt{\frac{5}{2}}$.

The centroid of $A B C$ lies on the median $C C^{\prime}$. It will also, by the assumption, lie on the angle bisector through $C$. Since the median and the angle bisector coincide, $A B C$ is isosceles with $A C=$ $B C=a$.

Furthermore, the centroid lies on the median $B B^{\prime}$ and the bisector of $\angle D B C$, again by hypothesis. By the Angle Bisector Theorem,

$$
\frac{B^{\prime} D}{B D}=\frac{B^{\prime} C}{B C}=\frac{a / 2}{a}=\frac{1}{2}
$$

The triangles $A B D \sim A C C^{\prime}$ since they have equal angles, whence

$$
\frac{1}{a}=\frac{A B}{A C}=\frac{A D}{A C^{\prime}}=\frac{a / 2-B^{\prime} D}{1 / 2}=a-B D
$$

Using the fact that the length of the altitude $C C^{\prime}$ is $\sqrt{a^{2}-\frac{1}{4}}$, this leads to

$$
a^{2}-1=a B D=2|A B C|=\sqrt{a^{2}-\frac{1}{4}},
$$

or, equivalently,

$$
a^{2}-1=\sqrt{a^{2}-\frac{1}{4}}
$$

Clearly, $a>1$, and the only solution is $a=\sqrt{\frac{5}{2}}$.

problem_match: # Problem 13.


problem: In the non-isosceles triangle $A B C$ the altitude from $A$ meets side $B C$ in $D$. Let $M$ be the midpoint of $B C$ and let $N$ be the reflection of $M$ in $D$. The circumcircle of the triangle $A M N$ intersects the side $A B$ in $P \neq A$ and the side $A C$ in $Q \neq A$. Prove that $A N, B Q$ and $C P$ are concurrent.

solution:
. Without loss of generality, we assume the order of the points on $B C$ to be $B, M, D, N$, $C$. This implies that $P$ is on the segment $A B$ and $Q$ is on the segment $A C$.

Since $D$ is the midpoint of $M N$ and $A D$ is perpendicular to $M N$, the line $A D$ is the perpendicular bisector of $M N$, which contains the circumcentre of $\triangle A M N$. As $A$ is on the perpendicular bisector of $M N$, we have $|A M|=|A N|$. We now have $\angle A P M=\angle A Q N$. Therefore

$$
\angle C Q N=180^{\circ}-\angle A Q N=180^{\circ}-\angle A P M=\angle B P M \text {. }
$$

Furthermore, as $N M P Q$ is cyclic, we have

$$
\angle N Q P=180^{\circ}-\angle N M P=\angle B M P \text {. }
$$

Hence

$$
\angle A Q P=180^{\circ}-\angle C Q N-\angle N Q P=180^{\circ}-\angle B P M-\angle B M P=\angle P B M=\angle A B C .
$$

Similarly,

$$
\angle A P Q=\angle B C A \text {. }
$$

Now we have $\triangle A P Q \sim \triangle A C B$. So

$$
\frac{|A P|}{|A Q|}=\frac{|A C|}{|A B|}
$$

Furthermore, $\angle M A B=\angle M A P=\angle M N P=\angle B N P$, so $\triangle B M A \sim \triangle B P N$, and hence

$$
\frac{|B N|}{|B P|}=\frac{|B A|}{|B M|}
$$

We also have $\angle C A M=\angle Q A M=180^{\circ}-\angle Q N M=\angle Q N C$. This implies $\triangle C M A \sim \triangle C Q N$, so

$$
\frac{|C Q|}{|C N|}=\frac{|C M|}{|C A|}
$$

Putting everything together, we find

$$
\frac{|B N|}{|B P|} \cdot \frac{|C Q|}{|C N|} \cdot \frac{|A P|}{|A Q|}=\frac{|B A|}{|B M|} \cdot \frac{|C M|}{|C A|} \cdot \frac{|A C|}{|A B|}
$$

As $|B M|=|C M|$, the right-hand side is equal to 1 . This means that

$$
\frac{|B N|}{|N C|} \cdot \frac{|C Q|}{|Q A|} \cdot \frac{|A P|}{|P B|}=1
$$

With Ceva's theorem we can conclude that $A N, B Q$ and $C P$ are concurrent.

problem_match: # Problem 14.


solution:
. We consider the same configuration as in Solution 1. Let $K$ be the second intersection of $A D$ with the circumcircle of $\triangle A M N$. Since $D$ is the midpoint of $M N$ and $A D$ is perpendicular to $M N$, the line $A D$ is the perpendicular bisector of $M N$, which contains the circumcentre of $\triangle A M N$. So $A K$ is a diameter of this circumcircle. Now we have $\angle B P K=90^{\circ}=\angle B D K$, so $B P D K$ is a cyclic quadrilateral. Also, $A, M, N, K, P$ and $Q$ are concyclic. Using both circles, we find

$$
180^{\circ}-\angle C Q P=\angle A Q P=\angle A K P=\angle D K P=\angle D B P=\angle C B P .
$$

This implies that $B P Q C$ is cyclic as well. Using the power theorem we find $A P \cdot A B=A Q \cdot A C$, with directed lengths. Also, $B N \cdot B M=B P \cdot B A$ and $C N \cdot C M=C Q \cdot C A$. Hence

$$
A P \cdot A B \cdot B N \cdot B M \cdot C Q \cdot C A=A Q \cdot A C \cdot B P \cdot B A \cdot C N \cdot C M
$$

Changing the signs of all six lengths on the right-hand side and replacing $M C$ by $B M$, we find

$$
A P \cdot A B \cdot B N \cdot B M \cdot C Q \cdot C A=Q A \cdot C A \cdot P B \cdot A B \cdot N C \cdot B M
$$

Cleaning this up, we have

$$
A P \cdot B N \cdot C Q=Q A \cdot P B \cdot N C,
$$

implying

$$
\frac{B N}{N C} \cdot \frac{C Q}{Q A} \cdot \frac{A P}{P B}=1
$$

With Ceva's theorem we can conclude that $A N, B Q$ and $C P$ are concurrent.


problem: In triangle $A B C$, the interior and exterior angle bisectors of $\angle B A C$ intersect the line $B C$ in $D$ and $E$, respectively. Let $F$ be the second point of intersection of the line $A D$ with the circumcircle of the triangle $A B C$. Let $O$ be the circumcentre of the triangle $A B C$ and let $D^{\prime}$ be the reflection of $D$ in $O$. Prove that $\angle D^{\prime} F E=90^{\circ}$.

solution:
. Note that $A B \neq A C$, since otherwise the exterior angle bisector of $\angle B A C$ would be parallel to $B C$. So assume without loss of generality that $A B<A C$. Let $M$ be the midpoint of $B C$ and let $F^{\prime}$ the reflection of $F$ in $O$, which is also the second intersection of the line $A E$ with the circumcircle of $\triangle A B C$. We now have

$$
\angle D^{\prime} F O=\angle O F^{\prime} D \text {. }
$$

Since $\angle D M F^{\prime}=90^{\circ}=\angle D A F^{\prime}$, the quadrilateral $M D A F^{\prime}$ is cyclic, thus

$$
\angle O F^{\prime} D=\angle M F^{\prime} D=\angle M A D \text {. }
$$

Furthermore, $\angle F M E=90^{\circ}=\angle F A E$, so $F M A E$ is cyclic as well. This implies that

$$
\angle M A D=\angle M A F=\angle M E F .
$$

Combining these three equalities we find that $\angle D^{\prime} F O=\angle M E F$, thus

$$
\angle D^{\prime} F E=\angle D^{\prime} F O+\angle O F E=\angle M E F+\angle M F E=180^{\circ}-\angle E M F=90^{\circ} .
$$

problem_match: # Problem 15.


solution:
. Again, assume $A B<A C$ and define $F^{\prime}$ as in the previous solution. Let $G$ be the intersection of the lines $D F^{\prime}$ and $E F$.

We can easily see that $F A$ is perpendicular to $E F^{\prime}$, and $B C$ to $F F^{\prime}$. Now, in triangle $\triangle E F F^{\prime}$, we have that $F D$ and $E D$ are altitudes, so $D$ is the orthocentre of this triangle. Now, $F^{\prime} D$ is an altitude

as well and we find that $F^{\prime} G$ is perpendicular to $E F$. Since $F F^{\prime}$ is a diameter of the circumcircle of $\triangle A B C, G$ must lie on this circle as well.

We now find

$$
\angle E F A=\angle G F A=\angle G F^{\prime} A=\angle D F^{\prime} A \text {. }
$$

Also, $\angle D F^{\prime} F=\angle D^{\prime} F F^{\prime}$. This implies that

$$
\angle D^{\prime} F E=\angle D^{\prime} F F^{\prime}+\angle F^{\prime} F A+\angle A F E=\angle D F^{\prime} F+\angle F^{\prime} F A+\angle A F^{\prime} D=\angle F^{\prime} F A+\angle A F^{\prime} F \text {. }
$$

Now, in triangle $\triangle A F F^{\prime}$ we have

$$
\angle F^{\prime} F A+\angle A F^{\prime} F=180^{\circ}-\angle F A F^{\prime}=90^{\circ},
$$

as required.


solution:
. Again, assume $A B<A C$. We first consider the case $\angle B A C=90^{\circ}$. Define $F^{\prime}$ as in the previous solution. Now $O$ and $D^{\prime}$ lie on $B C$, so $\triangle D^{\prime} F O$ and $\triangle D F O$ are mirror images with respect to $F F^{\prime}$, while $\triangle O F E$ and $\triangle O F^{\prime} E$ are mirror images with respect to $B C$. We find that

$$
\angle D^{\prime} F E=\angle D^{\prime} F O+\angle O F E=\angle D F O+\angle O F^{\prime} E=\angle A F F^{\prime}+\angle F F^{\prime} A=180^{\circ}-\angle F A F^{\prime}=90^{\circ} .
$$

Now assume that $\angle B A C \neq 90^{\circ}$. We consider the configuration where $\angle B A C<90^{\circ}$. Let $M$, $N$ and $L$ be the midpoints of the line segments $B C, D E$ and $D F$, respectively. Note that $N$ is the circumcentre of $\triangle A D E$, so we find

$$
\begin{aligned}
\angle N A F=\angle N A D=\angle N D A & =\angle D A C+\angle A C D \\
& =\frac{1}{2} \angle A+\angle A C D=\angle B A F+\angle A C D=\angle B C F+\angle A C D=\angle A C F .
\end{aligned}
$$

Hence $N A$ is tangent to the circumcircle of $\triangle A B C$, thus $N A \perp O A$. Furthermore, we have $N M \perp$ $O M$, so $A O M N$ is cyclic with $O N$ as diameter. Now, since $L$ is the circumcentre of $\triangle D M F$, we find

$$
\angle L M N=\angle L M D=\angle L D M=\angle A D N=\angle D A N=\angle L A N
$$

so $A N L M$ is cyclic. Combining this with what we found before, we now conclude that $A O M L N$ is cyclic with $O N$ as diameter, thus $\angle O L N=90^{\circ}$. Using a dilation with centre $D$ and factor 2 we now can conclude $\angle D^{\prime} F E=\angle O L N=90^{\circ}$.

In case $\angle B A C>90^{\circ}$, the proof is similar (the cyclic quadrilateral will this time be $A M O N$ ).


solution:
. We consider the configuration where $C, D, B$ and $E$ are on the line $B C$ in that order. The other configuration can be solved analogously. Let $P$ and $R$ be the feet of the perpendiculars from $D^{\prime}$ and $O$ to the line $A D$, respectively, and let $Q$ and $S$ be the feet of the perpendiculars from $D^{\prime}$ and $O$ to the line $C D$, respectively. Since $D^{\prime}$ is the reflection of $D$ with respect to $O$, we have $P R=R D$. Since we also have $O A=O F$ and therefore $R A=R F$, we obtain $A D=P F$. Similarly, $C D=B Q$. By Pythagoras's theorem,

$$
D^{\prime} F^{2}=D^{\prime} P^{2}+P F^{2}=4 O R^{2}+A D^{2}=4 O A^{2}-4 A R^{2}+A D^{2}=4 O A^{2}-A F^{2}+A D^{2}
$$

and

$$
D^{\prime} E^{2}=D^{\prime} Q^{2}+E Q^{2}=4 O S^{2}+E Q^{2}=4 O B^{2}-4 B S^{2}+E Q^{2}=4 O B^{2}-B C^{2}+(E B+C D)^{2} .
$$

And since $\angle E A F=90^{\circ}$ we have

$$
E F^{2}=A E^{2}+A F^{2} .
$$

As $O A=O B$, we conclude that

$$
\begin{array}{r}
D^{\prime} F^{2}+E F^{2}-D^{\prime} E^{2}=\left(4 O A^{2}-A F^{2}+A D^{2}\right)+\left(A E^{2}+A F^{2}\right)-\left(4 O B^{2}-B C^{2}+(E B+C D)^{2}\right) \\
=A E^{2}+A D^{2}+B C^{2}-(E B+C D)^{2}
\end{array}
$$

By Pythagoras's theorem again, we obtain $A E^{2}+A D^{2}=E D^{2}$, and hence

$$
D^{\prime} F^{2}+E F^{2}-D^{\prime} E^{2}=E D^{2}+B C^{2}-(E B+C D)^{2} .
$$

We have

$$
\begin{aligned}
E D^{2}+B C^{2} & =(E B+B D)^{2}+(B D+C D)^{2} \\
& =E B^{2}+B D^{2}+2 \cdot E B \cdot B D+B D^{2}+C D^{2}+2 \cdot B D \cdot C D \\
& =E B^{2}+C D^{2}+2 \cdot B D \cdot(E B+B D+C D) \\
& =E B^{2}+C D^{2}+2 \cdot B D \cdot E C .
\end{aligned}
$$

By the internal and external bisector theorems, we have

$$
\frac{B D}{C D}=\frac{B A}{C A}=\frac{B E}{C E},
$$

hence

$$
E D^{2}+B C^{2}=E B^{2}+C D^{2}+2 \cdot C D \cdot B E=(E B+C D)^{2} .
$$

So

$$
D^{\prime} F^{2}+E F^{2}-D^{\prime} E^{2}=0,
$$

which implies that $\angle D^{\prime} F E=90^{\circ}$.

solution_match: Solution 4


problem:
Denote by $P(n)$ the greatest prime divisor of $n$. Find all integers $n \geq 2$ for which

$$
P(n)+\lfloor\sqrt{n}\rfloor=P(n+1)+\lfloor\sqrt{n+1}\rfloor .
$$

(Note: $\lfloor x\rfloor$ denotes the greatest integer less than or equal to $x$.)

solution:
Answer: The equality holds only for $n=3$.

It is easy to see that $P(n) \neq P(n+1)$. Therefore we need also that $\lfloor\sqrt{n}\rfloor \neq\lfloor\sqrt{n+1}\rfloor$ in order for equality to hold. This is only possible if $n+1$ is a perfect square. In this case,

$$
\lfloor\sqrt{n}\rfloor+1=\lfloor\sqrt{n+1}\rfloor
$$

and hence $P(n)=P(n+1)+1$. As both $P(n)$ and $P(n+1)$ are primes, it must be that $P(n)=3$ and $P(n+1)=2$.

It follows that $n=3^{a}$ and $n+1=2^{b}$, and we are required to solve the equation $3^{a}=2^{b}-1$. Calculating modulo 3 , we find that $b$ is even. Put $b=2 c$ :

$$
3^{a}=\left(2^{c}-1\right)\left(2^{c}+1\right) .
$$

As both factors cannot be divisible by 3 (their difference is 2 ), $2^{c}-1=1$. From this we get $c=1$, which leads to $n=3$.

problem_match: # Problem 16.


problem: Find all positive integers $n$ for which $n^{n-1}-1$ is divisible by $2^{2015}$, but not by $2^{2016}$.

solution:
Since $n$ must be odd, write $n=2^{d} u+1$, where $u, d \in \mathbf{N}$ and $u$ is odd. Now

$$
n^{n-1}-1=\left(n^{2^{d}}-1\right)(\underbrace{n^{2^{d} \cdot(u-1)}+\cdots+n^{2^{d} \cdot 1}+1}_{u}),
$$

and hence $2^{2015} \|\left(n^{n-1}-1\right)$ iff $2^{2015} \|\left(n^{2^{d}}-1\right)$. (The notation $p^{k} \| m$ denotes that $p^{k} \mid m$ and $p^{k+1} \nmid m$.)

We factorise once more:

$$
\begin{aligned}
n^{2^{d}}-1 & =(n-1)(n+1) \underbrace{\left(n^{2}+1\right) \cdots\left(n^{2^{d-1}}+1\right)}_{d-1} \\
& =2^{d} u \cdot 2\left(2^{d-1} u+1\right) \underbrace{\left(n^{2}+1\right) \cdots\left(n^{2^{d-1}}+1\right)}_{d-1} .
\end{aligned}
$$

If $k \geq 1$, then $2 \| n^{2^{k}}+1$, and so from the above

$$
2^{2 d} \| 2^{d} u \cdot 2 \cdot \underbrace{\left(n^{2}+1\right) \cdots\left(n^{2^{d-1}}+1\right)}_{d-1} \quad \text { and } \quad 2^{2015-2 d} \|\left(2^{d-1} u+1\right)
$$

It is easy to see that this is the case exactly when $d=1$ and $u=2^{2013} v-1$, where $v$ is odd.

Hence the required numbers are those of the form

$$
n=2\left(2^{2013} v-1\right)+1=2^{2014} v-1
$$

for $v$ a positive odd number.

problem_match: # Problem 17.


problem: Let $f(x)=x^{n}+a_{n-1} x^{n-1}+\cdots+a_{0}$ be a polynomial of degree $n \geq 1$ with $n$ (not necessarily distinct) integer roots. Assume that there exist distinct primes $p_{0}, p_{1}, \ldots, p_{n-1}$ such that $a_{i}>1$ is a power of $p_{i}$, for all $i=0, \ldots, n-1$. Find all possible values of $n$.

solution:
Obviously all the roots have to be negative by the positivity of the coefficients. If at least two of the roots are unequal to -1 , then both of them have to be powers of $p_{0}$. Now Vieta's formulæ yield $p_{0} \mid a_{1}$, which is a contradiction. Thus we can factor $f$ as

$$
f(x)=\left(x+a_{0}\right)(x+1)^{n-1}
$$

Expanding yields

$$
a_{2}=\left(\begin{array}{c}
n-1 \\
1
\end{array}\right)+a_{0}\left(\begin{array}{c}
n-1 \\
2
\end{array}\right) \quad \text { and } \quad a_{n-2}=a_{0}\left(\begin{array}{l}
n-1 \\
n-2
\end{array}\right)+\left(\begin{array}{l}
n-1 \\
n-3
\end{array}\right)
$$

If $n \geq 5$, we see that $2 \neq n-2$ and so the two coefficients above are relatively prime, being powers of two distinct primes. However, depending on the parity of $n$, we have that $a_{2}$ and $a_{n-2}$ are both divisible by $n-1$ or $\frac{n-1}{2}$, which is a contradiction.

For $n=1,2,3,4$, the following polynomials meet the requirements:

$$
\begin{aligned}
& f_{1}(x)=x+2 \\
& f_{2}(x)=(x+2)(x+1)=x^{2}+3 x+2 \\
& f_{3}(x)=(x+3)(x+1)^{2}=x^{3}+5 x^{2}+7 x+3 \\
& f_{4}(x)=(x+2)(x+1)^{3}=x^{4}+5 x^{3}+9 x^{2}+7 x+2
\end{aligned}
$$

problem_match: # Problem 18.


problem:
Three pairwise distinct positive integers $a, b, c$, with $\operatorname{gcd}(a, b, c)=1$, satisfy

$$
a\left|(b-c)^{2}, \quad b\right|(c-a)^{2} \quad \text { and } \quad c \mid(a-b)^{2} \text {. }
$$

Prove that there does not exist a non-degenerate triangle with side lengths $a, b, c$.

solution:
First observe that these numbers are pairwise coprime. Indeed, if, say, $a$ and $b$ are divisible by a prime $p$, then $p$ divides $b$, which divides $(a-c)^{2}$; hence $p$ divides $a-c$, and therefore $p$ divides $c$. Thus, $p$ is a common divisor of these three numbers, a contradiction.

Now consider the number

$$
M=2 a b+2 b c+2 a c-a^{2}-b^{2}-c^{2} .
$$

It is clear from the problem condition that $M$ is divisible by $a, b, c$, and therefore $M$ is divisible by $a b c$.

Assume that a triangle with sides $a, b, c$ exists. Then $a<b+c$, and so $a^{2}<a b+a c$. Analogously, we have $b^{2}<b c+b a$ and $c^{2}<c a+c b$. Summing these three inequalities leads to $M>0$, and hence $M \geq a b c$.

On the other hand,

$$
a^{2}+b^{2}+c^{2}>a b+b c+a c
$$

and therefore $M<a b+b c+a c$. Supposing, with no loss of generality, $a>b>c$, we must have $M<3 a b$. Taking into account the inequality $M \geq a b c$, we conclude that $c=1$ or $c=2$ are the only possibilities.

For $c=1$ we have $b<a<b+1$ (the first inequality is our assumption, the second is the triangle inequality), a contradiction.

For $c=2$ we have $b<a<b+2$, i.e. $a=b+1$. But then $1=(a-b)^{2}$ is not divisible by $c=2$.

problem_match: # Problem 19.


problem:
For any integer $n \geq 2$, we define $A_{n}$ to be the number of positive integers $m$ with the following property: the distance from $n$ to the nearest non-negative multiple of $m$ is equal to the distance from $n^{3}$ to the nearest non-negative multiple of $m$. Find all integers $n \geq 2$ for which $A_{n}$ is odd.

(Note: The distance between two integers $a$ and $b$ is defined as $|a-b|$.)

solution:
For an integer $m$ we consider the distance $d$ from $n$ to the nearest multiple of $m$. Then $m \mid n \pm d$, which means $n \equiv \pm d \bmod m$. So if, for some $m$, the distance from $n$ to the nearest multiple of $m$ is equal to the distance from $n^{3}$ to the nearest multiple of $m$, then $n \equiv \pm n^{3} \bmod m$.

On the other hand, if $n \equiv \pm n^{3} \bmod m$, then there exists a $0 \leq d \leq \frac{1}{2} m$ such that $n \equiv \pm d \bmod m$ and $n^{3} \equiv \pm d \bmod m$, so the distance from $n$ to the nearest multiple of $m$ is equal to the distance from $n^{3}$ to the nearest multiple of $m$.

We conclude that we need to count the number of positive integers $m$ such that $n \equiv \pm n^{3} \bmod m$, or, equivalently, $m \mid n^{3}-n$ or $m \mid n^{3}+n$. That is,

$$
\begin{aligned}
& A_{n}=\mid\left\{m \in \mathbf{Z}^{+}|m| n^{3}-n \text { or } m \mid n^{3}+n\right\} \mid \\
& =\left|\left\{m \in \mathbf{Z}^{+}|m| n^{3}-n\right\}\right|+\left|\left\{m \in \mathbf{Z}^{+}|m| n^{3}+n\right\}\right|-\mid\left\{m \in \mathbf{Z}^{+}|m| n^{3}-n \text { and } m \mid n^{3}+n\right\} \mid \\
& =\left|\left\{m \in \mathbf{Z}^{+}|m| n^{3}-n\right\}\right|+\left|\left\{m \in \mathbf{Z}^{+}|m| n^{3}+n\right\}\right|-\left|\left\{m \in \mathbf{Z}^{+}|m| \operatorname{gcd}\left(n^{3}-n, n^{3}+n\right)\right\}\right| \\
& =\tau\left(n^{3}-n\right)+\tau\left(n^{3}+n\right)-\tau\left(\operatorname{gcd}\left(n^{3}-n, n^{3}+n\right)\right),
\end{aligned}
$$

where $\tau(k)$ denotes the number of (positive) divisors of a positive integer $k$.

Recall that $\tau(k)$ is odd if and only if $k$ is a square. Furthermore, we have

$$
\operatorname{gcd}\left(n, n^{2} \pm 1\right)=1
$$

So if $n^{3} \pm n$ were a square, then both $n$ and $n^{2} \pm 1$ would be squares. But $n^{2} \pm 1$ is not a square, since $n \geq 2$ and the only consecutive squares are 0,1 . Hence neither $n^{3}-n$ nor $n^{3}+n$ is a square, so the first two terms $\tau\left(n^{3}-n\right)$ and $\tau\left(n^{3}+n\right)$ are both even. Hence $A_{n}$ is odd if and only if $\operatorname{gcd}\left(n^{3}-n, n^{3}+n\right)$ is a square.

We have

$$
\operatorname{gcd}\left(n^{2}-1, n^{2}+1\right)=\operatorname{gcd}\left(n^{2}-1,2\right)= \begin{cases}1 & \text { if } n \text { even } \\ 2 & \text { if } n \text { odd }\end{cases}
$$

Hence,

$$
\operatorname{gcd}\left(n^{3}-n, n^{3}+n\right)= \begin{cases}n & \text { if } n \text { even } \\ 2 n & \text { if } n \text { odd }\end{cases}
$$

Note that $2 n$ for $n$ odd is never a square, since it has exactly one factor of 2 . We conclude that $A_{n}$ is odd if and only if $n$ is an even square.

problem_match: # Problem 20.