problem: There are 2022 equally spaced points on a circular track $\gamma$ of circumference 2022. The points are labeled $A_{1}, A_{2}, \ldots, A_{2022}$ in some order, each label used once. Initially, Bunbun the Bunny begins at $A_{1}$. She hops along $\gamma$ from $A_{1}$ to $A_{2}$, then from $A_{2}$ to $A_{3}$, until she reaches $A_{2022}$, after which she hops back to $A_{1}$. When hopping from $P$ to $Q$, she always hops along the shorter of the two $\operatorname{arcs} \overparen{P Q}$ of $\gamma$; if $\overline{P Q}$ is a diameter of $\gamma$, she moves along either semicircle. Determine the maximal possible sum of the lengths of the 2022 arcs which Bunbun traveled, over all possible labellings of the 2022 points.

solution: Replacing 2022 with $2 n$, the answer is $2 n^{2}-2 n+2$. (When $n=1011$, the number is 2042222.) ![](https://cdn.mathpix.com/cropped/2024_11_19_5c8ecd58885c530bab97g-03.jpg?height=402&width=899&top_left_y=1202&top_left_x=586)  【 Construction. The construction for $n=5$ shown on the left half of the figure easily generalizes for all $n$.  Remark. The validity of this construction can also be seen from the below proof. ब First proof of bound. Let $d_{i}$ be the shorter distance from $A_{2 i-1}$ to $A_{2 i+1}$. Claim - The distance of the leg of the journey $A_{2 i-1} \rightarrow A_{2 i} \rightarrow A_{2 i+1}$ is at most $2 n-d_{i}$.   That means the total distance is at most  $$ \sum_{i=1}^{n}\left(2 n-d_{i}\right)=2 n^{2}-\left(d_{1}+d_{2}+\cdots+d_{n}\right) $$  Claim - We have  $$ d_{1}+d_{2}+\cdots+d_{n} \geq 2 n-2 $$


solution: Replacing 2022 with $2 n$, the answer is $2 n^{2}-2 n+2$. (When $n=1011$, the number is 2042222.) ![](https://cdn.mathpix.com/cropped/2024_11_19_5c8ecd58885c530bab97g-03.jpg?height=402&width=899&top_left_y=1202&top_left_x=586)  【 Construction. The construction for $n=5$ shown on the left half of the figure easily generalizes for all $n$.  Remark. The validity of this construction can also be seen from the below proof. Second proof of bound. Draw the $n$ diameters through the $2 n$ arc midpoints, as shown on the right half of the figure for $n=5$ in red.  Claim (Interpretation of distances) - The distance between any two points equals the number of diameters crossed to travel between the points.  With this in mind, call a diameter critical if it is crossed by all $2 n$ arcs. Claim - At most one diameter is critical.  Claim - Every diameter is crossed an even number of times.   This immediately implies that the maximum possible total distance is achieved when one diameter is crossed all $2 n$ times, and every other diameter is crossed $2 n-2$ times, for a total distance of at most  $$ n \cdot(2 n-2)+2=2 n^{2}-2 n+2 $$


problem: Let $A B C$ be an acute triangle. Let $M$ be the midpoint of side $B C$, and let $E$ and $F$ be the feet of the altitudes from $B$ and $C$, respectively. Suppose that the common external tangents to the circumcircles of triangles $B M E$ and $C M F$ intersect at a point $K$, and that $K$ lies on the circumcircle of $A B C$. Prove that line $A K$ is perpendicular to line $B C$.

solution: \I Inversion solution submitted by Ankan Bhattacharya and Nikolai Beluhov. Let $H$ be the orthocenter of $\triangle A B C$. We use inversion in the circle with diameter $\overline{B C}$. We identify a few images:  - The circumcircles of $\triangle B M E$ and $\triangle C M F$ are mapped to lines $B E$ and $C F$. - The common external tangents are mapped to the two circles through $M$ which are tangent to lines $B E$ and $C F$. - The image of $K$, denoted $K^{*}$, is the second intersection of these circles. - The assertion that $K$ lies on $(A B C)$ is equivalent to $K^{*}$ lying on $(B H C)$.  However, now $K^{*}$ is simple to identify directly: it's just the reflection of $M$ in the bisector of $\angle B H C$. ![](https://cdn.mathpix.com/cropped/2024_11_19_5c8ecd58885c530bab97g-06.jpg?height=1148&width=1218&top_left_y=237&top_left_x=419)  In particular, $\overline{H K^{*}}$ is a symmedian of $\triangle B H C$. However, since $K^{*}$ lies on $(B H C)$, this means $\left(H K^{*} ; B C\right)=-1$.  Then, we obtain that $\overline{B C}$ bisects $\angle H M K^{*} \equiv \angle H M K$. However, $K$ also lies on $(A B C)$, which forces $K$ to be the reflection of $H$ in $\overline{B C}$. Thus $\overline{A K} \perp \overline{B C}$, as wanted.


solution: ๆ Solution with coaxial circles (Pitchayut Saengrungkongka). Let $H$ be the orthocenter of $\triangle A B C$. Let $Q$ be the second intersection of $\odot(B M E)$ and $\odot(C M F)$. We first prove the following well-known properties of $Q$.  Claim - $Q$ is the Miquel point of $B C E F$. In particular, $Q$ lies on both $\odot(A E F)$ and $\odot(A B C)$.   Claim - $A(Q, H ; B, C)=-1$.    Claim - $Q T$ is tangent to $\odot(B Q C)$.   $$ \begin{aligned} \frac{B T}{T C} & =\frac{T B \cdot T M}{T C \cdot T M} \\ & =\frac{\operatorname{pow}(T, \odot(B M E))}{\operatorname{pow}(T, \odot(C M F))} \\ & =\frac{\operatorname{pow}(K, \odot(B M E))}{\operatorname{pow}(K, \odot(C M F))} \\ & =\left(\frac{r_{\odot(B M E)}}{r_{\odot(C M F)}}\right)^{2} \\ & =\left(\frac{B Q / \sin \angle Q M B}{C Q / \sin \angle Q M C}\right)^{2} \\ & =\frac{B Q^{2}}{C Q^{2}} \end{aligned} $$  implying the result. To finish, let $O$ be the center of $\odot(A B C)$. Then, from the claim, $\angle O Q T=90^{\circ}=$ $\angle O M T$, so $O$ also lies on $\odot(Q M T K)$. Thus, $\angle O K T=90^{\circ}$, so $K T$ is also tangent to $\odot(A B C)$ as well. This implies that $Q B K C$ is harmonic quadrilateral, and the result follows from the second claim.


solution: 【 Solution by Luke Robitaille. Let $Q$ be the second intersection of $\odot(B M E)$ and $\odot(C M F)$. We use the first two claims of the previous solution. In particular, $Q \in$ $\odot(A B C)$. We have the following claim.  Claim (Also appeared in ISL 2017 G7) - We have $\measuredangle Q K M=\measuredangle Q B M+\measuredangle Q C M$.   $$ \begin{aligned} \measuredangle Q K M & =\measuredangle Q^{\prime} Q M^{\prime}+\measuredangle Q M^{\prime} M \\ & =\measuredangle Q C M+\measuredangle Q B M, \end{aligned} $$  as desired. Now, we extend $K M$ to meet $\odot(A B C)$ again at $Q_{1}$. We have  $$ \begin{aligned} \measuredangle Q_{1} Q B=\measuredangle Q_{1} K B & =\measuredangle Q_{1} K Q+\measuredangle Q C B \\ & =\measuredangle M K Q+\measuredangle Q K B \\ & =(\measuredangle M B Q+\measuredangle M C Q)+\measuredangle Q C B \\ & =\measuredangle C B Q, \end{aligned} $$  implying that $Q Q_{1} \| B C$. This implies that $Q B K C$ is harmonic quadrilateral, so we are done.


solution: I Synthetic solution due to Andrew Gu (Harvard 2026). Define $O_{1}$ and $O_{2}$ as the circumcenters of $(B M E)$ and $(C M F)$. Let $T$ be the point on $(A B C)$ such that $\overline{A T} \perp \overline{B C}$. Denote by $L$ the midpoint of minor arc $\overparen{B C}$.  We are going to ignore the condition that $K$ lies on the circumcircle of $A B C$, and prove the following unconditional result:  ## Proposition  The points $T, L, K$ are collinear.  This will solve the problem because if $K$ is on the circumcircle of $A B C$, it follows $K=T$ or $K=L$; but $K=L$ can never occur since $O_{1}$ and $O_{2}$ are obviously on different sides of line $L M$ so line $L M$ must meet $O_{1} O_{2}$ inside segment $O_{1} O_{2}$, and $K$ lies outside this segment. ![](https://cdn.mathpix.com/cropped/2024_11_19_5c8ecd58885c530bab97g-08.jpg?height=1243&width=1400&top_left_y=926&top_left_x=334)   Claim - Lines $A C$ and $L M$ meet at the antipode $Q_{1}$ of $B$ on $(B M E)$, so that $B P_{1} Q_{1} M$ is a rectangle. Similarly, lines $A B$ and $L M$ meet at the antipode $Q_{2}$ of $C$ on $(C M F)$, so that $C P_{2} Q_{2} M$ is a rectangle.   From this, it follows that $P_{1} Q_{1}=B M=\frac{1}{2} B C=M C=P_{2} Q_{2}$. Letting $r_{1}$ denote the radius of $\omega_{1}$ (and similarly for $\omega_{2}$ ), we deduce that $C Q_{1}=B Q_{1}=2 r_{1}$.  Claim - $K M=K L$.   $$ \measuredangle Q_{1} C L=\measuredangle A C L=\measuredangle A B L=\measuredangle Q_{2} B L=\measuredangle Q_{2} C L $$  The external angle bisector theorem then gives an equality of directed ratios  $$ \frac{L Q_{1}}{L Q_{2}}=\frac{\left|C Q_{1}\right|}{\left|C Q_{2}\right|}=\frac{\left|B Q_{1}\right|}{\left|C Q_{2}\right|}=\frac{2 r_{1}}{2 r_{2}}=\frac{r_{1}}{r_{2}} $$  Let the reflection of $M$ over $K$ be $P$; then $P$ lies on $\overline{P_{1} P_{2}}$ and  $$ \frac{P P_{1}}{P P_{2}}=\frac{2 K O_{1}}{2 K O_{2}}=\frac{K O_{1}}{K O_{2}}=\frac{r_{1}}{r_{2}}=\frac{L Q_{1}}{L Q_{2}} $$  where again the ratios are directed. Projecting everything onto line $L M$, so that $P_{1}$ lands at $Q_{1}$ and $P_{2}$ lands at $Q_{2}$, we find that the projection of $P$ must land exactly at $L$.  Claim - Line $K M$ is an external angle bisector of $\angle O_{1} M O_{2}$.  To finish, note that we know that $\overline{M P_{1}} \| \overline{C Q_{1}} \equiv \overline{A C}$ and $\overline{M P_{2}} \| \overline{B Q_{2}} \equiv \overline{A B}$, meaning the angles $\angle O_{1} M O_{2}$ and $\angle C A B$ have parallel legs. Hence, if $N$ is the antipode of $L$, it follows that $\overline{M K} \| \overline{A N}$. Now from $M K=K L$ and the fact that $A N L T$ is an isosceles trapezoid, we deduce that $\overline{L T}$ and $\overline{L K}$ are lines in the same direction (namely, the reflection of $M K \| A N$ across $\overline{B C}$ ), as needed.


solution: 【 Complex numbers approach with Apollonian circles, by Carl Schildkraut. We use complex numbers. As in the first approach, we will ignore the hypothesis that $K$ lies on ( $A B C$ ).  Let $Q:=(A H) \cap(A B C) \cap(A E F) \neq A$ be the Miquel point of $B F E C$ again. Construct the point $T$ on $(A B C)$ for which $A T \perp B C$; note that $T=-\frac{b c}{a}$. This time the unconditional result is:  ## Proposition  We have $Q, M, T, K$ are concyclic (or collinear) on an Apollonian circle of $\overline{O_{1} O_{2}}$.  This will solve the original problem since once $K$ lies on $(A B C)$ it must be either $Q$ or $T$. But since $K$ is not on $(B M E), K \neq Q$, it will have to be $T$.  We now prove the proposition. Suppose $(A B C)$ is the unit circle and let $A=a, B=b$, $C=c$. Let $H=a+b+c$ be the orthocenter of $\triangle A B C$. By the usual formulas,  $$ E:=\frac{1}{2}\left(a+b+c-\frac{b c}{a}\right) . $$  Let $O_{1}$ be the center of $(B M E)$ and $O_{2}$ be the center of $(C M F)$.  Claim (Calculation of the Miquel point) - We have $Q=\frac{2 a+b+c}{a\left(\frac{1}{a}+\frac{1}{b}+\frac{1}{c}\right)+1}$.  $$ 0=\frac{q-h}{q-a}+\frac{1 / q-\bar{h}}{1 / q-1 / a}=\frac{q-h}{q-a}-\frac{a(1-q \bar{h})}{q-a} $$  This solves to $q=\frac{h+a}{a \bar{h}+1}=\frac{2 a+b+c}{a \bar{h}+1}$.  Claim (Calculation of $O_{1}$ and $\left.O_{2}\right)-$ We have $O_{1}=\frac{b(2 a+b+c)}{2(a+b)}$ and $O_{2}=\frac{c(2 a+b+c)}{2(a+c)}$.   $$ \begin{aligned} O_{1} & =\operatorname{Circum}(B, M, E) \\ & =b+\frac{1}{2} \operatorname{Circum}\left(0, c-b, \frac{(a-b)(b-c)}{b}\right) \\ & =b-\frac{b-c}{2 b} \operatorname{Circum}(0, b, b-a) \\ & =b-\frac{b-c}{2 b}(b-\operatorname{Circum}(0, b, a)) \\ & =b-\frac{b-c}{2 b}\left(b-\frac{a b}{a+b}\right)=b-\frac{b(b-c)}{2(a+b)}=\frac{b(2 a+b+c)}{2(a+b)} \end{aligned} $$  Similarly, $O_{2}=\frac{c(2 a+b+c)}{2(a+c)}$. We are now going to prove the following: Claim - We have  $$ \frac{T O_{1}}{T O_{2}}=\frac{M O_{1}}{M O_{2}}=\frac{Q O_{1}}{Q O_{2}} $$   $$ M O_{1}=B O_{1}=\left|b-\frac{b(2 a+b+c)}{2(a+b)}\right|=\left|\frac{b(b-c)}{2(a+b)}\right|=\frac{1}{2}\left|\frac{b-c}{a+b}\right| $$  and $Q O_{1}=\left|r-\frac{b(2 a+b+c)}{2(a+b)}\right|=\left|1-\frac{b(a+h)}{2(a+b) r}\right|=\left|1-\frac{b(a \bar{h}+1)}{2(a+b)}\right|=\left|\frac{a-\frac{a b}{c}}{2(a+b)}\right|=\frac{1}{2}\left|\frac{b-c}{a+b}\right|$. This implies both (by symmetry) that $\frac{M O_{1}}{M O_{2}}=\frac{Q O_{1}}{Q O_{2}}=\left|\frac{a+c}{a+b}\right|$ and that $Q$ is on (BME) and $(C M F)$. Also,  $$ \frac{T O_{1}}{T O_{2}}=\frac{\left|\frac{b(2 a+b+c)}{2(a+b)}+\frac{b c}{a}\right|}{\left|\frac{c(2 a+b+c)}{2(a+c)}+\frac{b c}{a}\right|}=\left|\frac{\frac{b\left(2 a^{2}+a b+a c+2 a c+2 b c\right)}{2 a(a+b)}}{\frac{c\left(2 a^{2}+a b+a c+2 a b+2 b c\right)}{2 a(a+c)}}\right|=\left|\frac{a+c}{a+b}\right| \cdot\left|\frac{2 a^{2}+2 b c+a b+3 a c}{2 a^{2}+2 b c+3 a b+a c}\right| $$  if $z=2 a^{2}+2 b c+a b+3 a c$, then $a^{2} b c \bar{z}=2 a^{2}+2 b c+3 a b+a c$, so the second term has magnitude 1. This means $\frac{T O_{1}}{T O_{2}}=\frac{M O_{1}}{M O_{2}}=\frac{Q O_{1}}{Q O_{2}}$, as desired.  To finish, note that this common ratio is the ratio between the radii of these two circles, so it is also $\frac{K O_{1}}{K O_{2}}$. By Apollonian circles the points $\{Q, M, T, K\}$ lie on a circle or a line.


problem: Consider pairs $(f, g)$ of functions from the set of nonnegative integers to itself such that  - $f(0) \geq f(1) \geq f(2) \geq \cdots \geq f(300) \geq 0 ;$ - $f(0)+f(1)+f(2)+\cdots+f(300) \leq 300$; - for any 20 nonnegative integers $n_{1}, n_{2}, \ldots, n_{20}$, not necessarily distinct, we have  $$ g\left(n_{1}+n_{2}+\cdots+n_{20}\right) \leq f\left(n_{1}\right)+f\left(n_{2}\right)+\cdots+f\left(n_{20}\right) . $$  Determine the maximum possible value of $g(0)+g(1)+\cdots+g(6000)$ over all such pairs of functions.

solution: Replace $300=\frac{24 \cdot 25}{2}$ with $\frac{s(s+1)}{2}$ where $s=24$, and 20 with $k$. The answer is $115440=$ $\frac{k s(k s+1)}{2}$. Equality is achieved at $f(n)=\max (s-n, 0)$ and $g(n)=\max (k s-n, 0)$. To prove  $$ g\left(n_{1}+\cdots+n_{k}\right) \leq f\left(n_{1}\right)+\cdots+f\left(n_{k}\right) $$  write it as  $$ \max \left(x_{1}+\cdots+x_{k}, 0\right) \leq \max \left(x_{1}, 0\right)+\cdots+\max \left(x_{k}, 0\right) $$  with $x_{i}=s-n_{i}$. This can be proven from the $k=2$ case and induction. It remains to show the upper bound. For this problem, define a partition to be a nonincreasing function $p: \mathbb{Z}_{\geq 0} \rightarrow \mathbb{Z}_{\geq 0}$ such that $p(n)=0$ for some $n$. The sum of $p$ is defined to be $\sum_{n=0}^{\infty} p(n)$, which is finite under the previous assumption. Let $L=\mathbb{Z}_{\geq 0}^{2}$. The Young diagram of the partition is the set of points  $$ \mathcal{P}:=\{(x, y) \in L: y<p(x)\} . $$  The number of points in $\mathcal{P}$ is equal to the sum of $p$. The conjugate of a partition defined as  $$ p_{*}(n)=\text { the number of } i \text { for which } p(i)>n \text {. } $$  This is a partition with the same sum as $p$. Geometrically, the Young diagrams of $p$ and $p_{*}$ are reflections about $x=y$.  Since each $g(n)$ is independent, we may maximize each one separately for all $n$ and assume that  $$ g(n)=\min _{n_{1}+\cdots+n_{k}=n}\left(f\left(n_{1}\right)+\cdots+f\left(n_{k}\right)\right) . $$  The conditions of the problem statement imply that $f\left(\frac{s(s+1)}{2}\right)=0$. Then, for any $n \leq k \frac{s(s+1)}{2}$, there exists an optimal combination $\left(n_{1}, \ldots, n_{k}\right)$ in $\left(^{*}\right)$ where all $n_{i}$ are at most $\frac{s(s+1)}{2}$, by replacing any term in an optimum greater than $\frac{s(s+1)}{2}$ by $\frac{s(s+1)}{2}$ and shifting the excess to smaller terms (because $f$ is nonincreasing). Therefore we may extend $f$ to a partition by letting $f(n)=0$ for $n>\frac{s(s+1)}{2}$ without affecting the relevant values of $g$. Then $\left(^{*}\right)$ implies that $g$ is a partition as well.  The problem can be restated as follows: $f$ is a partition with sum $\frac{s(s+1)}{2}$, and $g$ is a partition defined by $\left(^{*}\right)$. Find the maximum possible sum of $g$. The key claim is that the problem is the same under conjugation.  Claim - Under these conditions, we have  $$ g_{*}(n)=\min _{n_{1}+\cdots+n_{k}=n}\left(f_{*}\left(n_{1}\right)+\cdots+f_{*}\left(n_{k}\right)\right) . $$   $$ \overline{\mathcal{G}}=\underbrace{\overline{\mathcal{F}}+\cdots+\overline{\mathcal{F}}}_{k \overline{\mathcal{F}}^{\prime} \mathrm{s}} $$  where + denotes set addition. This definition remains invariant under reflection about $x=y$, which swaps $f$ and $g$ with their conjugates.  Let $A$ be the sum of $g$. We now derive different bounds on $A$. First, by Hermite's identity  $$ n=\sum_{i=0}^{k-1}\left\lfloor\frac{n+i}{k}\right\rfloor $$  we have  $$ \begin{aligned} A & =\sum_{n=0}^{\infty} g(n) \\ & \leq \sum_{n=0}^{\infty} \sum_{i=0}^{k-1} f\left(\left\lfloor\frac{n+i}{k}\right\rfloor\right) \\ & =k^{2} \sum_{n=0}^{\infty} f(n)-\frac{k(k-1)}{2} f(0) \\ & =k^{2} \frac{s(s+1)}{2}-\frac{k(k-1)}{2} f(0) . \end{aligned} $$  By the claim, we also get the second bound $A \leq k^{2} \frac{s(s+1)}{2}-\frac{k(k-1)}{2} f_{*}(0)$. For the third bound, note that $f\left(f_{*}(0)\right)=0$ and thus $g\left(k f_{*}(0)\right)=0$. Moreover,  $$ g\left(q f_{*}(0)+r\right) \leq q \cdot f\left(f_{*}(0)\right)+(k-q-1) f(0)+f(r)=(k-q-1) f(0)+f(r), $$  so we have  $$ \begin{aligned} A & =\sum_{\substack{0 \leq q<k \\ 0 \leq r<f_{*}(0)}} g\left(q f_{*}(0)+r\right) \\ & \leq \frac{k(k-1)}{2} f_{*}(0) f(0)+k \sum_{0 \leq r<f_{*}(0)} f(r) \\ & =\frac{k(k-1)}{2} f_{*}(0) f(0)+k \frac{s(s+1)}{2} . \end{aligned} $$  Now we have three cases:  - If $f(0) \geq s$ then  $$ A \leq k^{2} \frac{s(s+1)}{2}-\frac{k(k-1)}{2} f(0) \leq \frac{k s(k s+1)}{2} $$  - If $f_{*}(0) \geq s$ then  $$ A \leq k^{2} \frac{s(s+1)}{2}-\frac{k(k-1)}{2} f_{*}(0) \leq \frac{k s(k s+1)}{2} $$  - Otherwise, $f(0) f_{*}(0) \leq s^{2}$ and  $$ A \leq \frac{k(k-1)}{2} f_{*}(0) f(0)+k \frac{s(s+1)}{2} \leq \frac{k s(k s+1)}{2} $$  In all cases, $A \leq \frac{k s(k s+1)}{2}$, as desired. Remark. One can estimate the answer to be around $k^{2} \frac{s(s+1)}{2}$ by observing the set addition operation "dilates" $\mathcal{F}$ by a factor of $k$, but significant care is needed to sharpen the bound.


problem: For nonnegative integers $a$ and $b$, denote their bitwise xor by $a \oplus b$. (For example, $9 \oplus 10=1001_{2} \oplus 1010_{2}=0011_{2}=3$.) Find all positive integers $a$ such that for any integers $x>y \geq 0$, we have  $$ x \oplus a x \neq y \oplus a y . $$

solution: Answer: the function $x \mapsto x \oplus a x$ is injective if and only if $a$ is an even integer. đ Even case. First, assume $\nu_{2}(a)=k>0$. We wish to recover $x$ from $c:=x \oplus a x$. Notice that:  - The last $k$ bits of $c$ coincide with the last $k$ bits of $x$. - Now the last $k$ bits of $x$ give us also the last $2 k$ bits of $a x$, so we may recover the last $2 k$ bits of $x$ as well. - Then the last $2 k$ bits of $x$ give us also the last $3 k$ bits of $a x$, so we may recover the last $3 k$ bits of $x$ as well. - ...and so on. đ Odd case. Conversely, suppose $a$ is odd. To produce the desired collision: Claim - Let $n$ be any integer such that $2^{n}>a$, and define  $$ x=\underbrace{1 \ldots 1}_{n}=2^{n}-1, \quad y=1 \underbrace{0 \ldots 0}_{n} 1=2^{n}+1 . $$  Then $x \oplus a x=y \oplus a y$.   $$ \begin{aligned} & a x=\overline{Q R} \Longrightarrow x \oplus a x=\overline{Q Q} \\ & a y=\overline{P P} \Longrightarrow y \oplus a y=\overline{Q Q} . \end{aligned} $$  We're done.


problem: Let $m$ and $n$ be fixed positive integers. Tsvety and Freyja play a game on an infinite grid of unit square cells. Tsvety has secretly written a real number inside of each cell so that the sum of the numbers within every rectangle of size either $m \times n$ or $n \times m$ is zero. Freyja wants to learn all of these numbers. One by one, Freyja asks Tsvety about some cell in the grid, and Tsvety truthfully reveals what number is written in it. Freyja wins if, at any point, Freyja can simultaneously deduce the number written in every cell of the entire infinite grid. (If this never occurs, Freyja has lost the game and Tsvety wins.) In terms of $m$ and $n$, find the smallest number of questions that Freyja must ask to win, or show that no finite number of questions can suffice.

solution: The answer is the following:  - If $\operatorname{gcd}(m, n)>1$, then Freyja cannot win. - If $\operatorname{gcd}(m, n)=1$, then Freyja can win in a minimum of $(m-1)^{2}+(n-1)^{2}$ questions.  First, we dispose of the case where $\operatorname{gcd}(m, n)>1$. Write $d=\operatorname{gcd}(m, n)$. The idea is that any labeling where each $1 \times d$ rectangle has sum zero is valid. Thus, to learn the labeling, Freyja must ask at least one question in every row, which is clearly not possible in a finite number of questions.  Now suppose $\operatorname{gcd}(m, n)=1$. We split the proof into two halves. 【 Lower bound. Clearly, any labeling where each $m \times 1$ and $1 \times m$ rectangle has sum zero is valid. These labelings form a vector space with dimension $(m-1)^{2}$, by inspection. (Set the values in an $(m-1) \times(m-1)$ square arbitrarily and every other value is uniquely determined.)  Similarly, labelings where each $n \times 1$ and $1 \times n$ rectangle have sum zero are also valid, and have dimension $(n-1)^{2}$.  It is also easy to see that no labeling other than the all-zero labeling belongs to both categories; labelings in the first space are periodic in both directions with period $m$, while labelings in the second space are periodic in both directions with period $n$; and hence any labeling in both categories must be constant, ergo all-zero.  Taking sums of these labelings gives a space of valid labelings of dimension $(m-1)^{2}+$ $(n-1)^{2}$. Thus, Freyja needs at least $(m-1)^{2}+(n-1)^{2}$ questions to win.   Claim (Periodicity) - Any valid labeling is doubly periodic with period $m n$.  Then both $m n \times N$ and $m n \times(N+1)$ rectangles have zero sum, so $m n \times 1$ rectangles have zero sum. This implies that any two cells with a vertical displacement of $m n$ are equal; similarly for horizontal displacements.  With that in mind, consider a valid labeling. It naturally corresponds to a generating function  $$ f(x, y)=\sum_{a=0}^{m n-1} \sum_{b=0}^{m n-1} c_{a, b} x^{a} y^{b} $$  where $c_{a, b}$ is the number in $(a, b)$. The generating function corresponding to sums over $n \times m$ rectangles is  $$ f(x, y)\left(1+x+\cdots+x^{m-1}\right)\left(1+y+\cdots+y^{n-1}\right)=f(x, y) \cdot \frac{x^{m}-1}{x-1} \cdot \frac{y^{n}-1}{y-1} . $$  Similarly, the one for $m \times n$ rectangles is  $$ f(x, y) \cdot \frac{x^{n}-1}{x-1} \cdot \frac{y^{m}-1}{y-1} . $$  Thus, the constraints for $f$ to be valid are equivalent to  $$ f(x, y) \cdot \frac{x^{m}-1}{x-1} \cdot \frac{y^{n}-1}{y-1} \quad \text { and } \quad f(x, y) \cdot \frac{x^{n}-1}{x-1} \cdot \frac{y^{m}-1}{y-1} $$  being zero when reduced modulo $x^{m n}-1$ and $y^{m n}-1$, or, letting $\omega=\exp (2 \pi i / m n)$, both terms being zero when powers of $\omega$ are plugged in.  To restate the constraints one final time, we need  $$ f\left(\omega^{a}, \omega^{b}\right) \cdot \frac{\omega^{a m}-1}{\omega^{a}-1} \cdot \frac{\omega^{b n}-1}{\omega^{b}-1}=f\left(\omega^{a}, \omega^{b}\right) \cdot \frac{\omega^{a n}-1}{\omega^{a}-1} \cdot \frac{\omega^{b m}-1}{\omega^{b}-1}=0 $$  for all $a, b \in\{0, \ldots, m n-1\}$. Claim - This implies that $f\left(\omega^{a}, \omega^{b}\right)=0$ for all but at most $(m-1)^{2}+(n-1)^{2}$ values of $(a, b) \in\{0, \ldots, m n-1\}^{2}$.   $$ \frac{\omega^{a m}-1}{\omega^{a}-1} \cdot \frac{\omega^{b n}-1}{\omega^{b}-1}=\frac{\omega^{a n}-1}{\omega^{a}-1} \cdot \frac{\omega^{b m}-1}{\omega^{b}-1}=0 . $$  This happens when (at least) one fraction in either product is zero.  - If the first fraction is zero, then either $n \mid a$ and $a>0$, or $m \mid b$ and $b>0$. - If the second fraction is zero, then either $m \mid a$ and $a>0$, or $n \mid b$ and $b>0$.  If the first condition holds in both cases, then $m n \mid a$, but $0<a<m n$, a contradiction. Thus if $n \mid a$, then we must have $n \mid b$, and similarly if $m \mid a$ then $m \mid b$.  The former case happens $(m-1)^{2}$ times, and the latter case happens $(n-1)^{2}$ times. Thus, at most $(m-1)^{2}+(n-1)^{2}$ values of $f\left(\omega^{a}, \omega^{b}\right)$ are nonzero.  Claim - The $(m n)^{2}$ equations $f\left(\omega^{a}, \omega^{b}\right)=0$ are linearly independent when viewed as linear equations in $(m n)^{2}$ variables $c_{a, b}$. Hence, any subset of these equations is also linearly independent.   It follows that the dimension of the space of valid labelings is at most $(m-1)^{2}+(n-1)^{2}$, as desired.  T Explicit version of winning algorithm by Freyja, from author. Suppose that $\operatorname{gcd}(m, n)=1$ and $m \leq n$. Let $[a, b]$ denote the set of integers between $a$ and $b$ inclusive.  Let Freyja ask about all cells $(x, y)$ in the two squares  $$ \begin{aligned} & S_{1}=[1, m-1] \times[1, m-1] \\ & S_{2}=[m, m+n-2] \times[1, n-1] . \end{aligned} $$  In the beginning, one by one, Freyja determines all values inside of the rectangle $Q:=$ $[1, m-1] \times[m, n-1]$. To that end, on each step she considers some rectangle with $m$ rows and $n$ columns such that its top left corner is in $Q$ and all of the other values in it have been determined already. In this way, Freyja uncovers all of $Q$, starting with its lower right corner and then proceeding upwards and to the left.  Thus Freyja can learn all numbers inside of the rectangle  $$ R:=[1, m+n-2] \times[1, n-1]=Q \cup S_{1} \cup S_{2} . $$  See the figure below for an illustration for $(m, n)=(5,8)$. The first cell of $Q$ is uncovered using the dotted green rectangle. ![](https://cdn.mathpix.com/cropped/2024_11_19_5c8ecd58885c530bab97g-18.jpg?height=783&width=909&top_left_y=1730&top_left_x=576)  We need one lemma:  ## Lemma  Let $m$ and $n$ be positive integers with $\operatorname{gcd}(m, n)=1$. Consider an unknown sequence of real numbers $z_{1}, z_{2}, \ldots, z_{s}$ with $s \geq m+n-2$. Suppose that we know the sums of all contiguous blocks of size either $m$ or $n$ in this sequence. Then we can determine all individual entries in the sequence as well.   Let $T$ be the rectangle $[1, m+n-2] \times\{n\}$. By looking at appropriate rectangles of sizes $m \times n$ and $n \times m$ such that their top row is contained within $T$ and all of their other rows are contained within $R$, Freyja can learn the sums of all contiguous blocks of values of sizes $m$ and $n$ within $T$. By the Lemma, it follows that Freyja can uncover all of $T$.  In this way, with the help of the Lemma, Freyja can extend her rectangular area of knowledge both upwards and downwards. Once its height reaches $m+n-2$, by the same method she will be able to extend it to the left and right as well. This allows Freyja to determine all values in the grid. Therefore, $(m-1)^{2}+(n-1)^{2}$ questions are indeed sufficient.  Let $m$ and $n$ be relatively prime positive integers. Consider an infinite grid of unit square cells coloured in such a way that every rectangle of size either $m \times n$ or $n \times m$ contains the same multiset of colours. Then the colouring is either doubly periodic with period length $m$ or doubly periodic with period length $n$. (Here, "doubly periodic with period length $s$ " means "both horizontally and vertically periodic with period length $s$ ".)   $$ f_{i j}(x, y):=\left\{\begin{array}{rll} +1 & \text { when }(x, y) \equiv(0,0) \text { or }(i, j) & (\bmod m) ; \\ -1 & \text { when }(x, y) \equiv(0, j) \text { or }(i, 0) & (\bmod m) ; \text { and } \\ 0 & \text { otherwise. } \end{array}\right. $$  Define $g_{i, j}$ similarly, but with $1 \leq i, j \leq n-1$ and " $\bmod m$ " everywhere replaced by " $\bmod$ $n$ ". First we show that if a linear combination $h:=\sum \alpha_{i, j} f_{i, j}+\sum \beta_{i, j} g_{i, j}$ of the $f_{i, j}$ and $g_{i, j}$ contains only two distinct values, then either all of the $\alpha_{i, j}$ vanish or all of the $\beta_{i, j}$ do. It follows that each colour, considered in isolation, is either doubly periodic with period length $m$ or doubly periodic with period length $n$. Finally, we check that different period lengths cannot mix.  On the other hand, if $m$ and $n$ are not relatively prime, then there exist infinitely many non-isomorphic valid colourings. Furthermore, when $\operatorname{gcd}(m, n)=2$, there exist valid colourings which are not horizontally periodic; and, when $\operatorname{gcd}(m, n) \geq 3$, there exist valid colourings which are neither horizontally nor vertically periodic.


problem: Fix a function $f: \mathbb{N} \rightarrow \mathbb{N}$ and for any $m, n \in \mathbb{N}$ define  $$ \Delta(m, n)=\underbrace{f(f(\ldots f}_{f(n) \text { times }}(m) \ldots))-\underbrace{f(f(\ldots f}_{f(m) \text { times }}(n) \ldots)) . $$  Suppose $\Delta(m, n) \neq 0$ for any distinct $m, n \in \mathbb{N}$. Show that $\Delta$ is unbounded, meaning that for any constant $C$ there exist $m, n \in \mathbb{N}$ with $|\Delta(m, n)|>C$.

solution: Suppose for the sake of contradiction that $|\Delta(m, n)| \leq N$ for all $m, n$. Note that $f$ is injective, as  $$ f(m)=f(n) \Longrightarrow \Delta(m, n)=0 \Longrightarrow m=n $$  as desired. Let $G$ be the "arrow graph" of $f$, which is the directed graph with vertex set $\mathbb{N}$ and edges $n \rightarrow f(n)$. The first step in the solution is to classify the structure of $G$. Injectivity implies that $G$ is a disjoint collection of chains (infinite and half-infinite) and cycles. We have the following sequence of claims that further refine the structure.  Claim - The graph $G$ has no cycles.  $$ f^{f(n)}\left(m_{1}\right)=f^{f(n)}\left(m_{2}\right) $$  for some $m_{1} \neq m_{2}$, which contradicts injectivity. Claim - The graph $G$ has at most $2 N+1$ chains.  $$ \left|\Delta\left(m_{i}, f^{B-f\left(m_{i}\right)}(1)\right)\right| \leq N \Longrightarrow\left|f^{B}(1)-f^{f B-f\left(m_{i}\right)+1}(1)\left(m_{i}\right)\right| \leq N . $$  Since the $m_{i} \mathrm{~S}$ are in different chains, we have that $f^{f\left(-f\left(m_{i}\right)+1\right.}(1)\left(m_{i}\right)$ are distinct for each $i$, which implies that $k \leq 2 N+1$, as desired.  Claim - The graph $G$ consists of exactly one half-infinite chain. Since there are only finitely many chains, $f^{f(c)}(n)$ achieves all sufficiently large positive integers, say all positive integers at least $M$. Fix $A$ and $B$ such that $B>A \geq M$.  If $f^{f(c)}(n) \in[A, B]$, then $f^{f(n)}(c) \in[A-N, B+N]$, and distinct $n$ generate distinct $f^{f(n)}(c)$ due to the structure of $G$. Therefore, we have at least $B-A+1$ good numbers in $[A-N, B+N]$, so there are at most $2 N$ bad numbers in $[A-N, B+N]$.  Varying $B$, this shows there are at most $2 N$ bad numbers at least $A-N$. Let $c$ be the starting point of the chain, so every integer is of the form $f^{k}(c)$, where $k \geq 0$. Define a function $g: \mathbb{Z}_{\geq 0} \rightarrow \mathbb{N}$ by  $$ g(k):=f^{k}(c) $$  Due to the structure of $G, g$ is a bijection. Define  $$ \delta(a, b):=\Delta\left(f^{a}(c), f^{b}(c)\right)=g(g(b+1)+a)-g(g(a+1)+b) $$  so the conditions are equivalent to $|\delta(a, b)| \leq N$ for all $a, b \in \mathbb{Z}_{\geq 0}$ and $\delta(a, b) \neq 0$ for $a \neq b$, which is equivalent to $g(a+1)-a \neq g(b+1)-b$ for $a \neq b$. This tells us that $g(x)-x$ is injective for $x \geq 1$.  ## Lemma  For all $M$, there exists a nonnegative integer $x$ with $g(x) \leq x-M$.   Now pick $B$ such that $g(B)+N \leq B$ and $g(B)>N$. Note that infinitely many such $B$ exist, since we can take $M$ to be arbitrarily small in the above lemma. Let  $$ t=\max \left\{g^{-1}(g(B)-N), g^{-1}(g(B)-N+1), \ldots, g^{-1}(g(B)+N)\right\} $$  Note that $g(t) \leq g(B)+N \leq B$, so we have  $$ |\delta(t-1, B-g(t))|=|g(B)-g(t-1+g(B+1-g(t)))| \leq N $$  so  $$ t-1+g(B+1-g(t)) \in\left\{g^{-1}(g(B)-N), g^{-1}(g(B)-N+1), \ldots, g^{-1}(g(B)+N)\right\} $$  so by the maximality of $t$, we must have $g(B+1-g(t))=1$, so $B+1-g(t)=g^{-1}(1)$. We have $|g(t)-g(B)| \leq N$, so  $$ \left|(B-g(B))+1-g^{-1}(1)\right| \leq N . $$  This is true for infinitely many values of $B$, so infinitely many values of $B-g(B)$ (by injectivity of $g(x)-x)$, which is a contradiction. This completes the proof.