olympiads / Czech /md /en-mo /en-a68angl.md
LxYxvv's picture
add pdf files
802d9fe
|
Raw
History Blame
47.7 kB

2019

68th Czech and Slovak
Mathematical Olympiad

First Round of the 68th Czech and Slovak

Mathematical Olympiad

Problems for the take-home part

(October 2018)

$\mathbb{N} / /(0)$

  1. Let $\left(a_{n}\right)_{n=1}^{\infty}$ be an infinite sequence such that for all positive integers $n$ we have

an+1=an2an24an+6 a_{n+1}=\frac{a_{n}^{2}}{a_{n}^{2}-4 a_{n}+6}

a) Find all values $a_{1}$ for which the sequence is constant.

b) Let $a_{1}=5$. Find $\left\lfloor a_{2018}\right\rfloor$.

(Vojtech Bálint)

Solution. a) Assume $\left(a_{n}\right){n=1}^{\infty}$ is constant. Then $a{2}=a_{1}$, hence

a1=a12a124a1+6 a_{1}=\frac{a_{1}^{2}}{a_{1}^{2}-4 a_{1}+6}

which rewrites as $a_{1}\left(a_{1}-2\right)\left(a_{1}-3\right)=0$. It follows that $a_{1} \in{0,2,3}$. On the other hand, once $a_{2}=a_{1}$, the sequence is clearly constant (formally e.g. by mathematical induction), thus any such $a_{1}$ indeed works.

b) Let $a_{1}=5$. Using the recurrence, we obtain $a_{2} \approx 2.27, a_{3} \approx 2.49, a_{4} \approx 2.77$, and so on. This leads to the following conjecture: For any $n \geqslant 2$ we have $2<a_{n}<3$. Below we prove the conjecture by mathematical induction.

For $n=2$ the conjecture holds. Suppose it holds for some fixed $n \geqslant 2$. Then

3an+1=3an2an24an+6=2(an3)2(an2)2+2>0,an+12=an2an24an+62=(6an)(an2)(an2)2+2>0. \begin{aligned} & 3-a_{n+1}=3-\frac{a_{n}^{2}}{a_{n}^{2}-4 a_{n}+6}=\frac{2\left(a_{n}-3\right)^{2}}{\left(a_{n}-2\right)^{2}+2}>0, \\ & a_{n+1}-2=\frac{a_{n}^{2}}{a_{n}^{2}-4 a_{n}+6}-2=\frac{\left(6-a_{n}\right)\left(a_{n}-2\right)}{\left(a_{n}-2\right)^{2}+2}>0 . \end{aligned}

This proves $2<a_{n+1}<3$, hence the proof of the conjecture is complete. In particular, $2<a_{2018}<3$ and the answer is $\left\lfloor a_{2018}\right\rfloor=2$.

  1. Let $A B C$ be an acute-angled triangle and let $D$ be the foot of its $A$-altitude. Denote by $D_{1}$ and $D_{2}$ the reflections of $D$ about $A B$ and $A C$, respectively. Points $E_{1}$ and $E_{2}$ lie on line $B C$ and satisfy $D_{1} E_{1} | A B$ and $D_{2} E_{2} | A C$. Prove that $D_{1}, D_{2}, E_{1}, E_{2}$ lie on a circle whose center lies on the circumcircle of $\triangle A B C$.

(Patrik Bak)

Solution. We first observe that $E_{1} E_{2} D_{2} D_{1}$ is a convex quadrilateral: As angles $\angle B$ and $\angle C$ are acute, $D$ is an interior point of side $B C$ and similarly the feet of the altitudes from $D$ in triangles $A B D$ and $A C D$ lie in the interiors of sides $A B$ and $A C$ respectively. The two mentioned feet together with $B$ and $C$ hence form a convex quadrilateral and homothety with center $D$ and coefficient 2 maps it to $E_{1} E_{2} D_{2} D_{1}$ (Fig. 1). Hence $E_{1} E_{2} D_{2} D_{1}$ is also convex.

Fig. 1

Now we prove that $E_{1} E_{2} D_{2} D_{1}$ is cyclic. The given line symmetries imply $\left|A D_{1}\right|=|A D|=\left|A D_{2}\right|$ and thus $A$ is the circumcenter of triangle $D_{1} D D_{2}$. Since $D_{1}$ and $D_{2}$ are separated by line $A D$, we have $\angle D_{1} D_{2} D=\frac{1}{2} \angle D_{1} A D$ from the inscribed angle theorem. It follows that $\angle D_{1} D_{2} D=\angle D_{1} A B=\angle D A B=90^{\circ}-\angle B$ (see Fig. 1). From $\angle D D_{2} E_{2}=90^{\circ}$ we infer

D1D2E2=D1D2D+DD2E2=(90B)+90=180B \angle D_{1} D_{2} E_{2}=\angle D_{1} D_{2} D+\angle D D_{2} E_{2}=\left(90^{\circ}-\angle B\right)+90^{\circ}=180^{\circ}-\angle B \text {. }

On the other hand, we have $\angle E_{2} E_{1} D_{1}=\angle B$ and therefore $E_{1} E_{2} D_{2} D_{1}$ is indeed a cyclic quadrilateral.

The center $S$ of its circumcircle is the intersection of perpendicular bisectors of $E_{1} D_{1}$ and $E_{2} D_{2}$. Since triangle $D E_{2} D_{2}$ is right with right angle at $D_{2}$ and $C$ is the midpoint of $D E_{2}$, the perpendicular bisector of $E_{2} D_{2}$ passes through $C$ (Fig. 2) and is perpendicular to $A C$. Analogously, the perpendicular bisector of $E_{1} D_{1}$ passes through $B$ and is perpendicular to $A B$. The two bisectors thus meet on the circumcircle of $A B C$ at the point diametrically opposite to $A$.

Fig. 2

Another solution. We show in a different way that $\angle D D_{2} D_{1}=90^{\circ}-\angle B$ which implies that $E_{1} E_{2} D_{2} D_{1}$ is cyclic. Points $E_{1}, E_{2}$ are images of $B, C$ respectively in the homothety with center in $D$ and coefficient 2. Denoting $A^{\prime}$ image of $A$ in this homothety (Fig.3) we observe that $A^{\prime}, D_{1}, E_{1}$ are collinear and so are $A^{\prime}, D_{2}, E_{2}$.

Fig. 3

Quadrilateral $A^{\prime} D_{1} D D_{2}$ is cyclic because of right angles $A^{\prime} D_{1} D$ and $A^{\prime} D_{2} D$ and hence $\angle D D_{2} D_{1}=\angle D_{1} A^{\prime} D$. Since $D_{1} A^{\prime} | B A$ we have also $\angle D_{1} A^{\prime} D=\angle B A D=90^{\circ}-\angle B$ and we are done.

Another solution. Let us define $A^{\prime}$ as in the previous solution. (Fig.3). Euclid's theorem applied to right triangles $A^{\prime} E_{1} D$ and $A^{\prime} E_{2} D$ yields $\left|A^{\prime} D\right|^{2}=\left|A^{\prime} D_{1}\right| \cdot\left|A^{\prime} E_{1}\right|$ and $\left|A^{\prime} D\right|^{2}=\left|A^{\prime} D_{2}\right| \cdot\left|A^{\prime} E_{2}\right|$. Hence

AD1AE1=AD2AE2 \left|A^{\prime} D_{1}\right| \cdot\left|A^{\prime} E_{1}\right|=\left|A^{\prime} D_{2}\right| \cdot\left|A^{\prime} E_{2}\right|

and as none of the segments $D_{1} E_{1}$ and $D_{2} E_{2}$ contain $A^{\prime}$, quadrilateral $D_{1} E_{1} E_{2} D_{2}$ is cyclic by power of a point.

Another solution. It suffices to prove that the perpendicular bisectors of $D_{1} E_{1}$, $D_{2} E_{2}, E_{1} E_{2}$ all pass through the point $A^{\prime}$ that lies on the circumcircle of triangle $A B C$, diametrically opposite to $A$. For the first two perpendicular bisectors, this assertion can be proved as in the final part of the first solution.

Arguing about the third bisector, let $P$ be the perpendicular projection of $A^{\prime}$ onto $B C$ and observe that $D$ is the projection of $A$. Since $A A^{\prime}$ is a diameter of the circumcircle of $\triangle A B C$, points $D$ and $P$ are symmetric about the midpoint of $B C$. We also have $E_{1} B=B D$ and $D C=C E_{2}$, hence $E_{1} P=E_{1} B+B P=B D+D C=$ $P C+C E_{2}=P E_{2}$ and we may conclude.

Remark. There are other possible solutions of this problem using the homothety with center in $D$ and coefficient 2. Then one can reformulate the first assertion naturally as to prove that the orthogonal projections of $D$ onto sides $A B$ and $A C$ lie together with $B$ and $C$ on a circle. The best way to prove the second assertion is to use Fig. 2.

  1. Find all non-negative integers $m, n$ such that $\left|4 m^{2}-n^{n+1}\right| \leqslant 3$. (Tomáš Jurík)

Solution. If $m=0$, then the examined relation is equivalent to $n^{n+1} \leqslant 3$. This is true for $n=0$ and $n=1$, whereas for $n \geqslant 2$ we have $n^{n+1} \geqslant 8$. Thus we get two solutions $(m, n)=(0,0)$ a $(m, n)=(0,1)$.

For $m=1$ we have the inequality $\left|4-n^{n+1}\right| \leqslant 3$. We can see that $n=0$ is not a solution and $n=1$ is. For $n \geqslant 2$ we have $\left|4-n^{n+1}\right|=n^{n+1}-4 \geqslant 4$. So we get another solution $(m, n)=(1,1)$.

From now on we assume $m \geqslant 2$ and rewrite the given inequality into the form $4 m^{2}=n^{n+1}+a$, where $a$ is an (unknown) integer, whose absolute value doesn't exceed 3. We will distinguish cases when $a=0,|a| \in{1,3}$ and $|a|=2$.

First, assume $4 m^{2}=n^{n+1}$. The left-hand side of the equation is an even square of an integer. This must be true for the right-hand side, therefore $n$ must be positive and even; let $n=2 k$. Then $n^{n+1}=(2 k)^{2 k+1}$, and since the exponent $2 k+1$ is odd, this is a perfect square only when its base $2 k$ is be a perfect square, that is, when $2 k=r^{2}$, where $r$ is a positive integer. Clearly $r$ must be even; let $r=2 l$. Then $k=2 l^{2}$ and $n=2 k=4 l^{2}$, where $l$ is a positive integer. Since $m$ is positive, the equation $4 m^{2}=n^{n+1}$ gives

m=nn+14=(4l2)4l2+12=(2l)4l2+12=l(2l)4l2 m=\sqrt{\frac{n^{n+1}}{4}}=\frac{\left(\sqrt{4 l^{2}}\right)^{4 l^{2}+1}}{2}=\frac{(2 l)^{4 l^{2}+1}}{2}=l \cdot(2 l)^{4 l^{2}}

In conclusion, for every positive integer $l$ we have the solution $(m, n)=\left(l(2 l)^{4 l^{2}}, 4 l^{2}\right)$.

Consider now cases $4 m^{2}=n^{n+1} \pm a$, where $a \in{1,3}$. From the fact that the right-hand side of the equation is even we conclude that $n^{n+1}$ is odd, which means that $n$ is odd. Since $m \geqslant 2$, we have $4 m^{2} \geqslant 16$, so we can rule out $n=-1$. Let $n=2 k+1$, where $k$ is a non-negative integer. Then we have

4m2=n2k+2±a(2m+nk+1)(2mnk+1)=±a \begin{aligned} 4 m^{2} & =n^{2 k+2} \pm a \\ \left(2 m+n^{k+1}\right)\left(2 m-n^{k+1}\right) & = \pm a \end{aligned}

Number $\pm a$ needs to be expressible as a product of two integers whose sum is equal to $\left(2 m+n^{k+1}\right)+\left(2 m-n^{k+1}\right)=4 m \geqslant 8$. At least one of them is greater than 3 , which cannot be true, because the only divisors of $\pm a$ are numbers $-3,-1,1,3$.

We're left to examine the last case $4 m^{2}=n^{n+1} \pm 2$. From this equation we can see that $n$ is not equal to 0 and is even, thus its power $n^{n+1}$ with the exponent greater than 1 is divisible by 4 , as well as $4 m^{2}$ on the left hand side. Thus the equation has no solutions.

Conclusion. All the solutions of the inequality are $(0,0),(0,1),(1,1)$ and infinitely many solutions of the form $(m, n)=\left(l(2 l)^{4 l^{2}}, 4 l^{2}\right)$, where $l$ is an arbitrary positive integer.

  1. Let $n \geqslant 3$ be odd and consider a set $M$ of $n$ positive integers. Show that the number of pairs $(p, q)$ of distinct elements from $M$, such that the arithmetic mean of $p$ and $q$ is an element of $M$, is at most $\frac{1}{2}(n-1)^{2}$.

(Martin Panák, Patrik Bak)

Solution. Denote by $x_{1}<x_{2}<\ldots<x_{n}$ the elements of $M$. Consider a fixed index $i$. If $x_{i}$ is the arithmetic mean of the elements $x_{j}<x_{k}$, then clearly $x_{j}<x_{i}<x_{k}$. Thus, the value of $j$ could be $1, \ldots, i-1$ ( $i-1$ options), whereas the value of $k$ could be $i+1, i+2, \ldots, n$ ( $n-i$ options). Furthermore, if $x_{i}$ is the arithmetic mean of distinct pairs $x_{j_{1}}<x_{k_{1}}$ and $x_{j_{2}}<x_{k_{2}}$, then $j_{1} \neq j_{2}$ and $k_{1} \neq k_{2}$ (if, for example, $j_{1}=j_{2}$, we easily have $k_{1}=k_{2}$, which is a contradiction with the fact that we picked distinct pairs). Thus, every possible value for $j$ or $k$ could be picked at most once, which means that the number of unordered pairs $p, q$ of distinct numbers of $M$, for which $x_{i}=\frac{1}{2}(p+q)$ with a given index $i$, is at $\operatorname{most} \min {i-1, n-i}$. We are looking for ordered pairs, thus there are at $\operatorname{most} 2 \min {i-1, n-i}$ such pairs.

Since $n$ is odd and greater than 1 , we can write $n=2 k+1$, where $k$ is a positive integer. If we sum our estimates for every possible value of the index $i$, i.e. $i=$ $1,2, \ldots, n$, we get that the examined number of pairs is at most

2(min{0,2k}+min{1,2k1}++min{k,k}++min{2k,0})==2(0+1++(k1)+k+(k1)+(k2)++1+0)==2(1+(k1))+2(2+(k2))++2((k1)+1)+2k=k2k. \begin{aligned} & 2(\min \{0,2 k\}+\min \{1,2 k-1\}+\cdots+\min \{k, k\}+\cdots+\min \{2 k, 0\})= \\ & =2(0+1+\ldots+(k-1)+k+(k-1)+(k-2)+\ldots+1+0)= \\ & =2(1+(k-1))+2(2+(k-2))+\cdots+2((k-1)+1)+2 k=k \cdot 2 k . \end{aligned}

Hence we are done, since $\frac{1}{2}(n-1)^{2}=2 k^{2}$.

Remark 1. If $n=2 k$, we can easily find that the number of examined pairs is at most

2(min{0,2k1}+min{1,2k2}++min{2k1,0})=2k(k1). 2(\min \{0,2 k-1\}+\min \{1,2 k-2\}+\ldots+\min \{2 k-1,0\})=2 k(k-1) .

We can easily verify that the uniform formula for both cases is $\left(\begin{array}{c}n \ 2\end{array}\right)-\left\lfloor\frac{n}{2}\right\rfloor$. and that the equality is attained for example for the set $M={1,2, \ldots, n}$.

Remark 2. The same proof works for real numbers instead of integers and also for a different mean (for example geometric mean $\sqrt{p q}$ or harmonic mean $2 p q /(p+q)$ ). It is possible to prove the estimate even for other "asymmetric" means, e.g. $\frac{2}{3} p+\frac{1}{3} q$, though we couldn't count the number of ordered pairs as the double of unordered ones.

  1. Given three positive real numbers $o, \rho, v$, construct a triangle $A B C$ with perimeter equal to $o$, the radius of its $A$-excircle equal to $\rho$, and the length of its $A$ altitude equal to $v$. Determine the number of solutions (non-congruent triangles) in terms of the given lengths.

(Patrik Bak)

Solution. Let $P$ be a point on the ray opposite to $B C$ such that $B P=B A$ and, similarly, let $Q$ be a point on the ray opposite to $C B$ such that $C Q=C A$. Then $P Q=o$.

Let $I_{a}$ be the $A$-excenter of $\triangle A B C$ (Fig. 4). Since $I_{a} B$ is the bisector of angle $A B P$ and the triangle $A B P$ is $B$-isosceles, line $I_{a} B$ is the perpendicular bisector of $A P$. Thus, $I_{a}$ lies on the perpendicular bisector of $A P$ and similarly for $A Q$. Point $I_{a}$ is therefore the circumcenter of $\triangle A P Q$ and it lies on the perpendicular bisector of $P Q$ too.

Fig. 4

With this insight, we can construct $\triangle A B C$ as follows: Let $P Q$ be a segment with length $o$ and let $M$ be its midpoint. Point $I_{a}$ satisfies $M I_{a} \perp P Q$ and $M I_{a}=\rho$. Point $A$ has to lie on a circle $k$ with center $I_{a}$ and radius $I_{a} P=I_{a} Q$ and also on a line $l$ parallel with $P Q$ with distance $v$ from $P Q$ in the opposite half-plane determined by $P Q$ than point $I_{a}$. Points $B, C$ can then be constructed in many ways, for example as the intersections of segment $P Q$ with the perpendicular bisectors of $A P$, $A Q$, respectively. Any triangle $A B C$ constructed in this way then satisfies all three requirements.

It remains to determine the number of solutions in terms of $o, \rho, v$. This is the same as asking for the number of intersections of $k$ and $l$.

Let $r=I_{a} P=\sqrt{\rho^{2}+(o / 2)^{2}}$ be the radius of $k$. When $r>\rho+v$, circle $k$ intersects line $l$ at two points $A_{1}, A_{2}$ and we get two triangles $A_{1} B_{1} C_{1}, A_{2} B_{2} C_{2}$ (Fig. 5). We count them as two separate solutions since they differ e.g. in the angle by $B$.

When $r=\rho+v$, circle $k$ is tangent to line $l$, we get a single intersection $A$ and a single solution $\triangle A B C$ (by symmetry, it will be isosceles).

Finally, when $r<\rho+v$, circle $k$ and line $l$ do not intersect and there is no solution.

To summarize:

ρ2+14o2>ρ+v:2 solutions, ρ2+14o2=ρ+v:1 solution, ρ2+14o2<ρ+v:0 solutions.  \begin{array}{ll} \sqrt{\rho^{2}+\frac{1}{4} o^{2}}>\rho+v: & \ldots 2 \text { solutions, } \\ \sqrt{\rho^{2}+\frac{1}{4} o^{2}}=\rho+v: & \ldots 1 \text { solution, } \\ \sqrt{\rho^{2}+\frac{1}{4} o^{2}}<\rho+v: & \ldots 0 \text { solutions. } \end{array}

Fig. 5

  1. Let $n \geqslant 3$ be a positive integer. Tom and Jerry play a game on a regular $n$-gon with one vertex marked as a trap. Initially, Jerry places a piece at one vertex of the n-gon. In each subsequent step, Tom says a positive integer and Jerry moves the piece by the given number of vertices either clockwise or counterclockwise. Find all $n \geqslant 3$ such that Jerry can place the piece and then move it in such a way that it never lands in the trap. How does the answer change if Tom knows $n$ but does not see where Jerry placed the piece and how he moves it? (Pavel Calábek)

Solution. Label the vertices $0,1, \ldots, n-1$ clockwise such that the trap is at vertex 0 . If the piece is at $a$ and Tom says $b$, Jerry can move the piece to vertices whose number gives remainder $a-b$ or $a+b$ when divided by $n$.

First we show that when $n$ has an odd divisor $d$ then Jerry wins by using the following strategy: Place the piece at a vertex not divisible by $d$ and keep moving it such that this property is preserved. Clearly, for any odd $d$, at least one vertex not divisible by $d$ exists (e.g. vertex 1) and no such vertex is a trap. It remains to show that if $d \nmid a$ then either $d \nmid a-b$ or $d \nmid a+b$. Assume otherwise. Then $d \mid(a+b)+(a-b)=2 a$ and since $d$ is odd, we conclude $d \mid a$, a contradiction.

On the other hand, we show that when $n=2^{k}$ is a power of 2 then Tom wins regardless of whether he sees Jerry's moves or not. We say that a non-trap vertex of the $n$-gon has degree $d$ if $2^{d}$ is the highest power of 2 dividing $d$. Further, we set the degree of node 0 equal to $k$.

First we describe Tom's strategy when he does see Jerry's moves. The strategy is simple: If the piece is currently at a vertex with degree $d$ then Tom says $2^{d}$. The key observation is that the degree increases at each step: Indeed, if the current vertex is $2^{d} \cdot q$ ( $q$ odd) then the new one will be $2^{d} \cdot q \pm 2^{d}=2^{d} \cdot(q \pm 1)$ which is divisible by $2^{d+1}$ regardless of the sign. Thus the new vertex always has a higher degree than the current one and the trap is eventually reached.

Finally, we describe Tom's strategy when he does not see Jerry's moves. All Tom's moves will be of the form $2^{i}$ for some integer $i<k$. The key observation here is that when the current vertex has degree $d<i$ then after Tom says $2^{i}$ then the new vertex again has degree $d$ : Indeed, if $i>d$ then, for any odd number $q$, the remainder of $2^{d} \cdot q \pm 2^{i}$ when divided by $2^{k}$ is divisible by $2^{d}$ but not by $2^{d+1}$.

Formally, Tom's strategy will be a sequence $\left(S_{k-1}, S_{k-2}, \ldots, S_{0}\right)$ of shorter subsequences $S_{i}$ which are themselves defined by a downward induction as follows:

(i) $S(k-1)$ consists of a single move $2^{k-1}$.

(ii) For a given $i \in{k-2, k-1, \ldots, 1,0}$, the subsequence $S_{i}$ consists of a move $2^{i}$ followed by the (already defined) subsequences $S_{k-1}, S_{k-2}, \ldots, S_{i+1}$ one after the other.

As an example, when $k=4$ (that is, $n=16$ ), Tom's strategy consists of the moves

(23,22,23,21,23,22,23,20,23,22,23,21,23,22,23). \left(2^{3}, 2^{2}, 2^{3}, 2^{1}, 2^{3}, 2^{2}, 2^{3}, 2^{0}, 2^{3}, 2^{2}, 2^{3}, 2^{1}, 2^{3}, 2^{2}, 2^{3}\right) .

It remains to show that this is a valid strategy for Tom. In fact, we prove a slightly stronger claim: A sequence $\left(S_{k-1}, \ldots, S_{i}\right)$ works if Jerry places the piece at any vertex with degree $d \geqslant i$. We proceed by strong downward induction on $i$. If $i=k-1$ then the claim is clear. Fix $i<k-1$ and assume the claim holds for all $i^{\prime} \in{i+1, \ldots, k-1}$. Assume Jerry placed the piece at a vertex with degree $d \geqslant i$. All the moves within the prefix $\left(S_{k-1}, S_{k-2}, \ldots, S_{d+1}\right)$ are of the form $2^{j}$ for some $j>d$, hence, by the above observation, the degree doesn't change. The first move of subsequence $S_{d}$ is $2^{d}$, hence the degree increases to some $d^{\prime}>d$. The remaining part of $S_{d}$ consists of $S_{k-1}, S_{k-2}, \ldots, S_{d+1}$. By the induction hypothesis, Tom wins after $S_{k-1}, S_{k-2}, \ldots, S_{d^{\prime}}$ at the latest.

Conclusion. When $n$ is a power of two, Tom wins regardless of whether he sees the moves. Otherwise, Jerry wins.

1. Find all primes $p, q$ such that the equation $x^{2}+p x+q=0$ has at least one integer root.
(Patrik Bak)

Solution. Denote the integer root by $a$. Then $a^{2}+p a+q=0$, hence $a \mid q$ which implies $a \in{ \pm 1, \pm q}$. We distinguish those four cases.

$\triangleright$ If $a=-1$ then $p-q=1$, hence $(p, q)=(3,2)$.

$\triangleright$ If $a=1$ then $p+q+1=0$, which has no solution.

$\triangleright$ If $a=q$ then $q^{2}+p q+q=0$ and after dividing by (positive) $q$ we get $q+p+1=0$ which has already been covered.

$\triangleright$ If $a=-q$ then $q^{2}-p q+q=0$ and after dividing by $q$ we get $p-q=1$ which has already been covered.

The only candidate is $(p, q)=(3,2)$ and we easily check that it is indeed a valid solution.

Another solution. Let $x_{1}, x_{2}$ be the roots of the equation. By Viète relations we get $x_{1}+x_{2}=-p$ and $x_{1} x_{2}=q$. The first equation implies that if one root is an integer then so is the other one. The second equation then implies that the roots are either 1 and $q$ or -1 and $-q$. In the first case we don't get any solutions, in the second case we require $p-q=1$ which gives a unique solution $(p, q)=(3,2)$ among primes.

  1. Let $A B C$ be an acute triangle with $A B<A C$. Points $D, E$ on the rays $A B, A C$, respectively, satisfy $A D=A C$ and $A E=A B$. Let $F$ be the point of intersection of the line passing through $D$ perpendicular to $A D$ and the line passing through $E$ perpendicular to $A E$. Show that $A F \perp B C$.

(Patrik Bak)

Solution. From the assumption $A B<A C$ we know that $D$ lies on the ray opposite to $B A$, whereas $E$ lies inside the segment $A C$. Triangles $A B C, A E D$ are congruent, since they share an angle at $A$ and the definition of $D$ and $E$ gives $A B=A E$ and $A C=A D$. This congruence gives $\angle A E D=\angle A B C=\beta<90^{\circ}$, since triangle $A B C$ is acute. Together with $\angle A E F=90^{\circ}$, this means that $\angle D E F=90^{\circ}-\beta$ (Fig.1). Quadrilateral $D F E A$ is cyclic, since both its angles at $D$ and $E$ are right. Then we have $\angle D A F=\angle D E F=90^{\circ}-\beta$. Denoting by $P$ the intersection point of $A F$ and $B C$, in triangle $A B P$ we then have $\angle P B A=\beta$ and $\angle B A P=\angle D A F=90^{\circ}-\beta$, hence $\angle A P B=90^{\circ}$, which means $A F \perp B C$.

Another solution. Denote by $P$ the perpendicular projection of $F$ onto $B C$. Convex quadrilaterals $B D F P$ and $C E P F$ are cyclic because of the right angles at $D, P$ and $E$. Furthermore, quadrilateral $B D C E$ is cyclic (Fig. 2), since it is an isosceles trapezoid,

Fig. 1

Fig. 2

because of the perpendicular bisectors of $B E$ and $C D$ being the internal angle bisector of $\angle B A C$. The radical axes of pairs of circumcircles of quadrilaterals $B D F P, C E P F$ and $B D C E$ are lines $B D, C E, P F$, therefore these three lines are concurrent, which means $A, P, F$ are collinear, hence $A F \perp B C$.

  1. Given a positive integer $n$, in each step we modify it as follows: If $n$ is even we divide it by 2; if it is odd we add 3 to it. Find all positive integers for which we get a number 1 after a finite number of steps.

(Ján Mazák)

Solution. Let $a>1$ be an integer. If it is even, then after one step we get $\frac{1}{2} a$. If it is odd, then we get $a+3$, which is even, so in the next step we get $\frac{1}{2}(a+3)$. Because of the assumption $a>1$ we have $\frac{1}{2} a<a$, and if $a>3$, then even $\frac{1}{2}(a+3)<a$. This shows that every number $a>1$ except for $a=3$ will decrease after at most two steps. Thus, starting from any number, in a finite number steps we reach either 1 (and then cycle $1 \rightarrow 2 \rightarrow 4 \rightarrow 1$ ) or 3 (and then cycle $3 \rightarrow 6 \rightarrow 3$ ).

Observe that our step preserves the divisibility by 3: Since $a$ gives either $a+3$, or $\frac{1}{2} a$, the number after one step is divisible by 3 if and only if the number before the step is. From this we see that if the initial number is divisible by 3, then we cannot ever get 1 (in fact, according to the first paragraph, we would always get 3). On the other hand, if we initially have a number not divisible by 3 , we cannot get a number divisible by 3 , i.e. we will get 1 .

In conclusion, the answer is the positive integers that are not divisible by 3 .

Remark. The problem resembles the first problem of the IMO 2017.

Second Round of the 68th Czech and Slovak Mathematical Olympiad
(January 15th, 2019)

$\mathbb{N} / /(0)$

  1. Let $n$ be a positive integer. Tom and Jerry play a game on a board consisting of a row of 2018 cells. Initially, Jerry places a piece at some cell. In each subsequent step, Tom says an integer from the interval $[1, n]$ and Jerry moves the piece by the said number of cells, by his choice either to the left or to the right. Tom wins whenever Jerry cannot make a move. Find the smallest $n$ for which Tom can pick numbers such that he wins after a finite number of moves.

(Josef Tkadlec)

Solution. We will show the smallest such $n$ is 1010 . Suppose $n \leqslant 1009$. Then Jerry has the following simple strategy: He places the piece at an arbitrary cell and then he moves it so that he does not immediately lose. He would not be able to make such a move only if there were at most $n-1$ cells to the left and at most $n-1$ cells to the right. In that case there would be at most $2(n-1)+1=2 n-1 \leqslant 2017$ cells, which is a contradiction.

Next assume $n=1010$. Label the cells $1,2, \ldots, 2018$ left to right and denote by $k$ the current position of the piece. If $k \in{1009,1010}$, Tom immediately wins by saying 1010. If $k<1009$, Tom can say $1009-k$. If Jerry moves right, the piece lands at a cell 1009 and Tom wins. If Jerry moves left, he moves the piece closer to the left border. Since the board is finite, Jerry cannot move left indefinitely and eventually he will have to move right and lose in the next step. Similarly, if the piece is at a cell $k>1010$, Tom wins by always saying $k-1010$.

Another solution. We describe another strategy for Tom when $n=1010$. This strategy forces a win in 3 steps. As before, label the cells 1,2, . , 2018 left to right and denote the current position of the piece by $k$. If $k \in{1009,1010}$, Tom says 1010 and wins immediately. If $k \leqslant 504$, Tom says $1009-k$. Since $k-(1009-k)<0$, Jerry has to move right and loses in the next step. Likewise, if $k \geqslant 1515$, Tom says $k-1010$ and forces Jerry to move to 1010 and lose in the next step. Next, if $505 \leqslant k \leqslant 1008$, Tom says 1010 , which forces Jerry to move right and place the piece at a cell $k^{\prime}$ satisfying $1515 \leqslant k^{\prime} \leqslant 2018$, from which Tom can force a win in two steps as described above. Finally, if $1011 \leqslant k \leqslant 1514$, Tom says 1010, which forces Jerry to move left to a cell $k^{\prime}$ satisfying $1 \leqslant k^{\prime} \leqslant 504$. Tom again wins in two more steps.

Another solution. We describe yet another strategy for Tom when $n=1010$. The strategy works even when Tom does not see the board. The strategy is simple: Tom keeps alternately saying 1010,1009 . We argue that this strategy makes Tom win.

If $k \in{1009,1010}$, the first move makes Tom win. If $k<1009$, there is only one way for Jerry to avoid losing in the first two steps: He has to first move right and then move left. This moves the piece to $k^{\prime}=k+1$. Likewise, if $k>1010$, Jerry has to first move left and then right (or lose immediately). This yields $k^{\prime}=k-1$. Either way, after every two steps, Jerry either loses or moves the piece closer to the middle, where he eventually loses.

  1. Find all pairs of integers $(m, n)$ that satisfy the equation $n^{n-1}=4 m^{2}+2 m+3$.

(Tomáš Jurík)

Solution. Clearly, the right-hand side is an odd integer, hence $n^{n-1}$ is also an odd integer which implies that $n$ is odd, $n-1$ is even and finally $n^{n-1}$ is a square of an integer.

For $m>1$, the inequalities $(2 m)^{2}<4 m^{2}+2 m+3<(2 m+1)^{2}$ imply that the equation does not have a solution.

For $m<-1$, we have the reversed inequalities $(2 m)^{2}>4 m^{2}+2 m+3>(2 m+1)^{2}$, so there are no solutions in this case either.

The only remaining options are $m \in{-1,0,1}$; by checking each of them we find the only solution $(m, n)=(1,3)$.

  1. Let $A B C$ be a triangle with $\angle B A C=90^{\circ}$. Points $D, E$ on its hypotenuse $B C$ satisfy $C D=C A, B E=B A$. Let $F$ be such a point inside $\triangle A B C$ that $D E F$ is an isosceles right triangle with hypotenuse DE. Find $\angle B F C$. (Patrik Bak)

Solution. We show that $F$ is the incenter of $\triangle A B C$. Simple angle-chasing in $\triangle B F C$ then yields $\angle B F C=180^{\circ}-\frac{1}{2} B-\frac{1}{2} C=135^{\circ}$.

Since $B A=B E$, triangle $B A E$ is isosceles and $\angle B A E=90^{\circ}-\frac{1}{2} \angle B$. Similarly, $\angle D A C=90^{\circ}-\frac{1}{2} \angle C$ and simple angle-chasing gives $\angle D A E=45^{\circ}$ (Fig. 1). This means that $F$ is the circumcenter of $\triangle A D E$ : Indeed, it lies in the same half-plane determined by $B C$ as $A$, and satisfies both $\angle D F E=90^{\circ}=2 \cdot 45^{\circ}=2 \angle D A E$ and $F E=F D$.

Being the circumcenter of $\triangle A D E$, point $F$ lies on the perpendicular bisectors of $A E$ and $A D$ which coincide with angle bisectors of $\angle B, \angle C$. Hence we are done.

Fig. 1

Another solution. We present another way to show that $F$ is the incenter of $\triangle A B C$. Denote by $M$ the midpoint of $D E$. Using the notation $B C=a, C A=b, A B=c$ we compute $D E=b+c-a$ (Fig. 2) and

BM=BD+DM=(ab)+12(b+ca)=12(a+cb), B M=B D+D M=(a-b)+\frac{1}{2}(b+c-a)=\frac{1}{2}(a+c-b),

hence $M$ is the point of contact of the incircle of $\triangle A B C$ with $B C$. Since $\triangle D E F$ is isosceles and right, we further have $M F=M D=\frac{1}{2} D E=\frac{1}{2}(b+c-a)$ which, according to a well-known formula, is the radius of an incircle of a right triangle. Thus $F$ is the incenter and we conclude as in the first solution.

Fig. 2

Remark. Once the contestant formulates a hypothesis that $F$ is the incenter of $\triangle A B C$, there are many other ways to prove it.

  1. Find the maximal value of $a^{2}+b^{2}+c^{2}$ for real numbers $a, b, c$ such that $a+b$, $b+c, c+a$ all lie in the interval $[0,1]$.

(Ján Mazák)

Solution. By symmetry of the problem, we can WLOG suppose $a \geqslant b \geqslant c$.

Then both $b-c$ and $b+c$ are non-negative (by our assumptions), hence their product will also be non-negative and $b^{2} \geqslant c^{2}$. Analogously, both $1-b-a$ and $1-b+a$ are non-negative and $(1-b)^{2} \geqslant a^{2}$.

Thus we have $a^{2}+b^{2}+c^{2} \leqslant(1-b)^{2}+2 b^{2}=1-b(2-3 b)$. The original restrictions on $a, b, c$ also impose certain restrictions on $b$ : we must have $1 \geqslant a+b \geqslant 2 b$ and $2 b \geqslant b+c \geqslant 0$, hence $b \in\left[0, \frac{1}{2}\right]$. But for $b$ in this interval it is clearly true that $b(2-3 b) \geqslant 0$, hence $a^{2}+b^{2}+c^{2} \leqslant 1$. This value is attained e.g. for $(a, b, c)=(1,0,0)$.

Remark. Note that we are maximizing a convex function on a convex set, therefore it is sufficient only to consider the boundary values where $a+b, b+c, c+a \in{0,1}$.

Final Round of the 68th Czech and Slovak Mathematical Olympiad
(March 24-27, 2019)

  1. Find all triplets $(x, y, z)$ of real numbers satisfying

x2yz=yz+1,y2zx=zx+1,z2xy=xy+1. \begin{aligned} & x^{2}-y z=|y-z|+1, \\ & y^{2}-z x=|z-x|+1, \\ & z^{2}-x y=|x-y|+1 . \end{aligned}

(Tomáš Jurík)

Solution. The system is symmetric, hence without loss of generality we can assume $x \geqslant y \geqslant z$. Removing the absolute values we get

x2yz=yz+1,y2zx=xz+1,z2xy=xy+1. \begin{aligned} & x^{2}-y z=y-z+1, \\ & y^{2}-z x=x-z+1, \\ & z^{2}-x y=x-y+1 . \end{aligned}

Subtracting (1) and (2), resp. (2) and (3) and rewriting we obtain

(xy)(x+y+z+1)=0(yz)(x+y+z1)=0. \begin{aligned} & (x-y)(x+y+z+1)=0 \\ & (y-z)(x+y+z-1)=0 . \end{aligned}

This implies that $x, y, z$ can not be all mutually different. However, they can't be all equal either as this would yield $0=1$ in the original system. Thus precisely two of them are equal and we get two cases: Either $x=y>z$ and $x+y+z=1$, or $x>y=z$ and $x+y+z=-1$.

Observe that $(x, y, z)$ is a solution if and only if $(-z,-y,-x)$ is a solution, thus it suffices to solve the first case $x=y>z$ and $x+y+z=1$. Then we have $z=1-2 x$. Plugging this into (1) we obtain $x(3 x-4)=0$, hence $x=0$ or $x=\frac{4}{3}$. This corresponds to triples $(x, y, z)$ equal to $(0,0,1)$ and $\left(\frac{4}{3}, \frac{4}{3},-\frac{5}{3}\right)$. The first triplet violates the assumption $x \geqslant y \geqslant z$, the other one indeed is a solution to the original system.

Together with the symmetries we discarded along the way, this gives 6 solutions:

(43,43,53),(53,43,43),(43,53,43),(53,43,43),(43,43,53),(43,53,43). \begin{gathered} \left(\frac{4}{3}, \frac{4}{3},-\frac{5}{3}\right),\left(-\frac{5}{3}, \frac{4}{3}, \frac{4}{3}\right),\left(\frac{4}{3},-\frac{5}{3}, \frac{4}{3}\right), \\ \left(\frac{5}{3},-\frac{4}{3},-\frac{4}{3}\right),\left(-\frac{4}{3},-\frac{4}{3}, \frac{5}{3}\right),\left(-\frac{4}{3}, \frac{5}{3},-\frac{4}{3}\right) . \end{gathered}

  1. Let $A B C D$ be a rectangle such that $A B=a \geqslant b=B C$. Construct points $P, Q$ on the line $B D$ such that $A P=P Q=Q C$. Determine the number of solutions in terms of $a, b$.

(Jaroslav Svrček)

Solution. Let $A^{\prime}, C^{\prime}$ be perpendicular projections of $A, C$ onto $B D$, respectively. Note that $A A^{\prime}=C C^{\prime}$ and that $A^{\prime}$ and $C^{\prime}$ are symmetric about the center $S$ of the rectangle.

Fix $d>0$. We investigate whether there exist points $P, Q$ on $B D$ such that $A P=P Q=Q C=d$.

Point $P$ has to lie on the line $B D$ and on the circle $k_{A}$ with center $A$ and radius $d$. Similarly, point $Q$ has to lie on the line $B D$ and on the circle $k_{C}$ with center $C$ and radius $d$.

If $d<A A^{\prime}$ then no such points exist. If $d=A A^{\prime}$ then the only possible candidate solution is $P=A^{\prime}, Q=C^{\prime}$ and it is valid if and only if $A^{\prime} C^{\prime}=A A^{\prime}$. Denoting $B D=c$ we have $A A^{\prime}=a b / c$ and $A^{\prime} C^{\prime}=c-2 \cdot b^{2} / c=\left(a^{2}-b^{2}\right) / c$ hence this solution is valid if and only if $a / b=\frac{1}{2}(1+\sqrt{5})$.

Finally, if $d>A A^{\prime}$ then $k_{A}$ intersects line $B D$ at two points. Denote by $A_{1}$ the one on the ray $A^{\prime} D$ and by $A_{2}$ the one on the ray $A^{\prime} B$. Similarly, let $B_{1}, B_{2}$ be the intersections of $k_{B}$ with rays $C^{\prime} D, C^{\prime} B$, respectively (Fig. 1). Since triangles $A A^{\prime} A_{1}$, $A A^{\prime} A_{2}, C C^{\prime} C_{1}, C C^{\prime} C_{2}$ are all congruent (HL), we have $A_{1} B_{1}=A_{2} B_{2}=A^{\prime} C^{\prime}$ and the pairs of points $\left(A_{1}, B_{2}\right)$ and $\left(A_{2}, B_{1}\right)$ are symmetric about $S$ (whereas pairs $\left(A_{1}, B_{1}\right),\left(A_{2}, B_{2}\right)$ are not). It remains to investigate which of the pairs $(P, Q) \in$ $\left{\left(A_{1}, B_{1}\right),\left(A_{2}, B_{2}\right),\left(A_{1}, B_{2}\right),\left(A_{2}, B_{1}\right)\right}$ are a valid solution.

Fig. 1

(a) Since $A_{1} B_{1}=A_{2} B_{2}=A^{\prime} C^{\prime}$, pairs $\left(A_{1}, B_{1}\right),\left(A_{2}, B_{2}\right)$ are a valid solution if and only if $d=A^{\prime} C^{\prime}$. We obtain those two solutions whenever $A^{\prime} C^{\prime}>A A^{\prime}$. By the same computation as above, the inequality $A^{\prime} C^{\prime}>A A^{\prime}$ holds if and only if $a / b>\frac{1}{2}(1+\sqrt{5})$. To construct the solutions, we simply construct circles $k_{A}, k_{B}$ with radii $A^{\prime} C^{\prime}$ and take the appropriate intersections with line $B D$.

(b) Since points $A_{1}, B_{2}$ are symmetric about $S$, a pair $\left(A_{1}, B_{2}\right)$ is a valid solution if and only if $A A_{1}=A_{1} B_{2}=2 \cdot A_{1} S$. Likewise, a pair $\left(A_{2}, B_{1}\right)$ is a valid solution if and only if $A A_{2}=2 \cdot A_{2} S$. Hence we get an extra solution for every point $X$ on $B D$ such that $A X=2 X S$. Regardless of $a$ and $b$, there are always two such points and they can be constructed for example as the intersections of line $B D$ with the Apollonius circle corresponding to points $A, S$ and ratio 2. Note that this includes the solution obtained earlier in the case $d=A A^{\prime}$.

To summarize, there are two solutions when $1 \leqslant a / b \leqslant \frac{1}{2}(1+\sqrt{5})$ and four solutions when $\frac{1}{2}(1+\sqrt{5})<a / b$.

  1. Let $a, b, c, n$ be positive integers such that the following conditions are met:

(i) every two of the numbers $a, b, c, a+b+c$ are coprime;

(ii) number $(a+b+c)(a+b)(b+c)(c+a)(a b+b c+c a)$ is a perfect $n$-th power. Prove that number abc can be expressed as a difference of two perfect n-th powers.

(Patrik Bak)

Solution. First we show that the numbers $A=(a+b+c)(a b+b c+c a)$ and $B=$ $(a+b)(b+c)(c+a)$ are coprime: Assume the opposite. Then there is a prime $p$ that dives both $A$ and $B$. Since $p \mid B$, it divides at least one of the numbers $a+b$, $b+c, c+a$, WLOG assume it is $a+b$. Then it cannot hold $p \mid a+b+c$, since then we would have $p \mid c$, which contradicts assumption (i). Thus we must have $p \mid a b+b c+c a=a b+c(a+b)$, from which we have $p \mid a b$, so $p$ divides at least one of the numbers $a, b$, which together with $p \mid a+b$ means that $p$ divides both numbers $a$ and $b$, which is, again, a contradiction with (i).

Since $A, B$ are coprime and their product $A B$ is a perfect $n$-th power, both $A$ and $B$ are perfect $n$-th powers. But $a b c=A-B$, which shows that $a b c$ can indeed be expressed as a difference of two perfect $n$-th powers.

Remark. Triple $(a, b, c)=(341,447,1235)$ meets the conditions for $n=2$.

  1. Let $A B C$ be an acute triangle. Point $P$ lies on the ray opposite to $B C$ such that $A B=B P$. Similarly, point $Q$ lies on the ray opposite to $C B$ such that $A C=C Q$. Let $J$ be the center of the $A$-excircle of triangle $A B C$ and $D, E$ its tangency points with lines $A B, A C$, respectively. Suppose that rays opposite to $D P$ and $E Q$ meet at $F \neq J$. Prove that $A F \perp F J$.

(Patrik Bak)

Solution. Since points $A, D, E, J$ lie on a circle with diameter $A J$, it suffices to prove that $F$ lies on this circle too (Fig. 2). Denote the tangency point of the excircle and the side $B C$ by $G$. From $A B=B P$ and $B D=B G$ we infer $\triangle A B G \cong \triangle P B D$ (SAS) and similarly $\triangle A C G \cong \triangle Q C E$. A straightforward angle-chasing then gives

AEF=180CEQ=180CGA=BGA=BDP=ADP |\angle A E F|=180^{\circ}-|\angle C E Q|=180^{\circ}-|\angle C G A|=|\angle B G A|=|\angle B D P|=|\angle A D P| \text {, }

thus $F$ lies on the circumcircle of $\triangle A D E$ as required.

Remark. Alternatively, after observing $\triangle A B G \cong \triangle P B D$ and $\triangle A C G \cong \triangle Q C E$, we can prove that $A D F E$ is cyclic by showing that the sum of interior angles by $A$ and $F$ equals $180^{\circ}$. This is again just angle-chasing.

  1. Prove that there are infinitely many integers that cannot be expressed in the form

2a+3b5c, 2^{a}+3^{b}-5^{c},

where $a, b, c$ are non-negative integers.

(Ján Mazák, Tomáš Bárta)

Solution. We will show that the examined expression never gives a remainder 7 when divided by 12 . The remainders of numbers $2^{a}, 3^{b}$ and $-5^{c}$ when divided by 12 are

Fig. 2

in the sets ${1,2,4,8},{1,3,9}$, and ${-1,-5}$, respectively. For every sum $s$ of three numbers from these sets it holds that $1+1-5 \leqslant s \leqslant 8+9-1$, that is $-3 \leqslant s \leqslant 16$. The only possible value of $s$ having a remainder 7 when divided by 12 is therefore $s=7$. However, if we pick -1 from the third set, we must pick numbers with a sum 8 from the first two, which is clearly not possible. Similarly we cannot pick -5 either, which proves that the given expression cannot be a number of the form $12 k+7$, where $k$ is an integer, and there are infinitely many such numbers.

Remark. It is readily checked that any other remainder modulo 12 can be attained. It is also true that for any $n<12$ the examined expression attains every possible remainder when divided by $n$. On the other hand, there are other $n$ 's for which there is a remainder that is not attained. The smallest such $n>12$ is 20 and the impossible remainders are 11,13 and 15 .

Another solution. Let us examine the remainders of the expression when divided by 20 . We will show that some odd remainder cannot be attained. The remainders of numbers $3^{b}$ and $-5^{c}$ when divided by 20 are numbers from the sets ${1,3,7,9}$ and ${-1,-5}$, respectively. Sums of two numbers from these sets attain at most $4 \cdot 2=$ 8 distinct values and all of them are even. Number $2^{a}$ has an odd remainder only for $a=0$, hence the whole expression $2^{a}+3^{b}-5^{c}$ can have at most 8 odd remainders, that is, there exist at least 2 odd remainders that are not attained.

Remark. There are, in fact, three such remainders, specifically 11, 13 and 15. On the other hand, one can check that any even remainder can be attained. (All the remainders that cannot be attained for $n \leqslant 30$ are visualized in the following schema.)

  1. Find all positive integers $n$ for which an $n \times n$ table can be filled with integers $1,2, \ldots, n^{2}$, each of them appearing once, so that the $2 n$ arithmetic means of the numbers in every row and column are all integers.

(Laura Vištanová)

Solution. Our goal is to make sure that the sum of numbers in every row and column is divisible by $n$. Thus we will restrict ourselves to filling the table with numbers $0,1, \ldots, n-1$, where each of them will be used exactly $n$ times. We will consider the following cases:

$\triangleright n$ is odd. Consider the table

012n1012n1012n1 \begin{array}{|ccccc} \hline 0 & 1 & 2 & \ldots & n-1 \\ 0 & 1 & 2 & \ldots & n-1 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 0 & 1 & 2 & \ldots & n-1 \\ \hline \end{array}

Every column contains $n$ equal numbers hence their sums are divisible by $n$. The sum of every row is equal to $0+1+\cdots+(n-1)=\frac{1}{2} n(n-1)$, which is also a multiple of $n$, since $n$ is odd.

$\triangleright n=4 k$ for some positive integer $k$. In this case we split the table $4 k \times 4 k$ into $4 k^{2}$ squares of a size $2 \times 2$ and consider the following pattern:

$x$ $4 k-x$
$4 k-x$ $x$

We need to place exactly $2 k$ of such squares for every $x=1,2, \ldots, 2 k-1$ and exactly $k$ of them for $x=2 k$. We are left with zeroes which we place into the $k$ remaining squares. Such a filling of the table will meet the required condition, since all the $2 \times 2$ squares have the sum of its rows and columns divisible by $4 k$ and their placement in the original table will not affect this divisibility.

$\triangleright n=4 k+2$ for some non-negative integer $k$. For $k=0($ or $n=2)$ it is easy to see the required filling does not exist. Let $k \geqslant 1$. In this case, we fill the left-top $4 \times 4$ subtable like this:

1 $4 k+1$ 0 0
$2 k$ $2 k+2$ 0 0
$2 k+1$ 0 $2 k$ 1
0 $2 k+1$ $2 k+2$ $4 k+1$

We see that so far the sum of every row and column is divisible by $4 k+2$. The rest of the table can then be divided into $2 \times 2$ squares and, similarly to the previous example, filled with the pattern

$x$ $4 k+2-x$
$4 k+2-x$ $x$

We need exactly $2 k$ of such squares for both $x=1$ and $x=2 k$, exactly $k$ such squares for $x=2 k+1$, and exactly $2 k+1$ such squares for every $x=2, \ldots, 2 k-1$. Clearly, this filling ensures that every row and column has the sum of its numbers divisible by $4 k+2$. Now we just put the remaining zeroes into the $k-1$ remaining $2 \times 2$ squares, which does not change any sum.

The required filling exists for every positive integer $n$ distinct from 2 .

Another solution. We will show alternative solutions for the cases $n=4 k$ and $n=4 k+2$, where $k$ is a positive integer.

$\triangleright n=4 k$ :

1 $4 k-1$ 2 $4 k-2$ $\ldots$ $2 k-1$ $2 k+1$ $2 k$ $2 k$
1 $4 k-1$ 2 $4 k-2$ $\ldots$ $2 k-1$ $2 k+1$ $2 k$ $2 k$
$\vdots$ $\vdots$ $\vdots$ $\vdots$ $\ddots$ $\vdots$ $\vdots$ $\vdots$ $\vdots$
1 $4 k-1$ 2 $4 k-2$ $\ldots$ $2 k-1$ $2 k+1$ $2 k$ $2 k$
1 $4 k-1$ 2 $4 k-2$ $\ldots$ $2 k-1$ $2 k+1$ 0 0
1 $4 k-1$ 2 $4 k-2$ $\ldots$ $2 k-1$ $2 k+1$ 0 0
$\vdots$ $\vdots$ $\vdots$ $\vdots$ $\ddots$ $\vdots$ $\vdots$ $\vdots$ $\vdots$
1 $4 k-1$ 2 $4 k-2$ $\ldots$ $2 k-1$ $2 k+1$ 0 0
1 $4 k-1$ 2 $4 k-2$ $\ldots$ $2 k-1$ $2 k+1$ 0 0

We see that we can pair up the numbers in the rows into pairs with a sum divisible by $4 k$, hence the row sums are divisible by $4 k$. In the first $4 k-2$ columns we have exactly $4 k$ equal numbers, so their sum is a multiple of $4 k$ too. The sums in the last two columns are equal to $2 k \cdot 2 k=4 k^{2}$, which is also divisible by $4 k$.

$\triangleright n=4 k+2$.

Notice that if we have arbitrary numbers $a_{1}, a_{2}, \ldots, a_{l}$, where each one can be used exactly $l$ times, then we can place them into an $l \times l$ table so that the sum in every row and column is be the same:

t(a1,a2,,al)=a1a2al1ala2a3ala1al1alal3al2ala1al2al1 t\left(a_{1}, a_{2}, \ldots, a_{l}\right)=\left|\begin{array}{ccccc} a_{1} & a_{2} & \ldots & a_{l-1} & a_{l} \\ a_{2} & a_{3} & \ldots & a_{l} & a_{1} \\ \vdots & \vdots & \ddots & \vdots & \vdots \\ a_{l-1} & a_{l} & \ldots & a_{l-3} & a_{l-2} \\ a_{l} & a_{1} & \ldots & a_{l-2} & a_{l-1} \end{array}\right|

We use this construction in the following way: We split the set ${0,1, \ldots, 4 k+1} \backslash$ ${0,2 k+1}$ in an arbitrary way into two disjoint sets $A, B$ such that $|A|=2 k-1$ and $|B|=2 k+1$. Now we create the following four sequences, each consisting of $2 k+1$ numbers:

0,0,A,2k+1,2k+1,A,B,B 0,0, A, \quad 2 k+1,2 k+1, A, \quad B, \quad B

and for every one of them we will create a table $(2 k+1) \times(2 k+1)$ using the described algorithm. Then we put these tables together into the final $(4 k+2) \times(4 k+2)$ like this:

t(0,0,A)t(B)t(B)t(2k+1,2k+1,A) \begin{array}{|cc|} \hline t(0,0, A) & t(B) \\ t(B) & t(2 k+1,2 k+1, A) \\ \hline \end{array}

In such a table, every number $0,1, \ldots, 4 k+1$ is used exactly $4 k+2$ times and it is readily checked that the sum of every row and column is divisible by $4 k+2$ : The sum of numbers in the sequences $A$ and $B$ is equal to $s=1+\cdots+(4 k+1)-(2 k+1)=$ $2 k(4 k+2)$, so half of the rows and columns have a sum $2 k(4 k+2)$ and the other half have a sum $(2 k+1)(4 k+2)$.