# Solutions of APMO 2017 Problem 1. We call a 5-tuple of integers arrangeable if its elements can be labeled $a$, $b, c, d, e$ in some order so that $a-b+c-d+e=29$. Determine all 2017-tuples of integers $n_{1}, n_{2}, \ldots, n_{2017}$ such that if we place them in a circle in clockwise order, then any 5 -tuple of numbers in consecutive positions on the circle is arrangeable. Answer: $n_{1}=\cdots=n_{2017}=29$. Solution. A valid 2017-tuple is $n_{1}=\cdots=n_{2017}=29$. We will show that it is the only solution. We first replace each number $n_{i}$ in the circle by $m_{i}:=n_{i}-29$. Since the condition $a-b+$ $c-d+e=29$ can be rewritten as $(a-29)-(b-29)+(c-29)-(d-29)+(e-29)=0$, we have that any five consecutive replaced integers in the circle can be labeled $a, b, c, d, e$ in such a way that $a-b+c-d+e=0$. We claim that this is possible only when all of the $m_{i}$ 's are 0 (and thus all of the original $n_{i}$ 's are 29). We work with indexes modulo 2017. Notice that for every $i, m_{i}$ and $m_{i+5}$ have the same parity. Indeed, this follows from $m_{i} \equiv m_{i+1}+m_{i+2}+m_{i+3}+m_{i+4} \equiv m_{i+5}(\bmod 2)$. Since $\operatorname{gcd}(5,2017)=1$, this implies that all $m_{i}$ 's are of the same parity. Since $m_{1}+m_{2}+m_{3}+m_{4}+m_{5}$ is even, all $m_{i}$ 's must be even as well. Suppose for the sake of contradiction that not all $m_{i}$ 's are zero. Then our condition still holds when we divide each number in the circle by 2 . However, by performing repeated divisions, we eventually reach a point where some $m_{i}$ is odd. This is a contradiction. Problem 2. Let $A B C$ be a triangle with $A B1$. Let $a, b, c$ be positive rational numbers such that $a b c=1$. Suppose there exist positive integers $x, y, z$ such that $a^{x}+b^{y}+c^{z}$ is an integer. Prove that $a, b, c$ are all powerful. Solution. Let $a=\frac{a_{1}}{b_{1}}, b=\frac{a_{2}}{b_{2}}$, where $\operatorname{gcd}\left(a_{1}, b_{1}\right)=\operatorname{gcd}\left(a_{2}, b_{2}\right)=1$. Then $c=\frac{b_{1} b_{2}}{a_{1} a_{2}}$. The condition that $a^{x}+b^{y}+c^{z}$ is an integer becomes $$ \frac{a_{1}^{x+z} a_{2}^{z} b_{2}^{y}+a_{1}^{z} a_{2}^{y+z} b_{1}^{x}+b_{1}^{x+z} b_{2}^{y+z}}{a_{1}^{z} a_{2}^{z} b_{1}^{x} b_{2}^{y}} \in \mathbb{Z} $$ which can be restated as $$ a_{1}^{z} a_{2}^{z} b_{1}^{x} b_{2}^{y} \mid a_{1}^{x+z} a_{2}^{z} b_{2}^{y}+a_{1}^{z} a_{2}^{y+z} b_{1}^{x}+b_{1}^{x+z} b_{2}^{y+z} . $$ In particular, $a_{1}^{z}$ divides the right-hand side. Since it divides the first and second terms in the sum, we conclude that $a_{1}^{z} \mid b_{1}^{x+z} b_{2}^{y+z}$. Since $\operatorname{gcd}\left(a_{1}, b_{1}\right)=1$, we have $a_{1}^{z} \mid b_{2}^{y+z}$. Let $p$ be a prime that divides $a_{1}$. Let $m, n \geq 1$ be integers such that $p^{n} \| a_{1}$ (i.e. $p^{n} \mid a_{1}$ but $\left.p^{n+1} \nmid a_{1}\right)$ and $p^{m} \| b_{2}$. The fact that $a_{1}^{z} \mid b_{2}^{y+z}$ implies $n z \leq m(y+z)$. Since $\operatorname{gcd}\left(a_{1}, b_{1}\right)=$ $\operatorname{gcd}\left(a_{2}, b_{2}\right)=1$, we have $p$ does not divide $b_{1}$ and does not divide $a_{2}$. Thus $$ p^{n z} \| a_{1}^{z} a_{2}^{y+z} b_{1}^{x} \text { and } p^{m(y+z)} \| b_{1}^{x+z} b_{2}^{y+z} $$ On the other hand, (1) implies that $$ p^{n z+m y} \mid a_{1}^{z} a_{2}^{y+z} b_{1}^{x}+b_{1}^{x+z} b_{2}^{y+z} . $$ If $n z1$. Thus each exponent in the prime decomposition of $a_{1}$ must be divisible by $k$. Hence $a_{1}$ is a perfect $k$-power which means $a$ is powerful. Similarly, $b$ and $c$ are also powerful. Problem 5. Let $n$ be a positive integer. A pair of $n$-tuples $\left(a_{1}, \ldots, a_{n}\right)$ and $\left(b_{1}, \ldots, b_{n}\right)$ with integer entries is called an exquisite pair if $$ \left|a_{1} b_{1}+\cdots+a_{n} b_{n}\right| \leq 1 $$ Determine the maximum number of distinct $n$-tuples with integer entries such that any two of them form an exquisite pair. Answer: The maximum is $n^{2}+n+1$. Solution. First, we construct an example with $n^{2}+n+1 n$-tuples, each two of them forming an exquisite pair. In the following list, $*$ represents any number of zeros as long as the total number of entries is $n$. - (*) - $(*, 1, *)$ - $(*,-1, *)$ - $(*, 1, *, 1, *)$ - $(*, 1, *,-1, *)$ For example, for $n=2$ we have the tuples $(0,0),(0,1),(1,0),(0,-1),(-1,0),(1,1),(1,-1)$. The total number of such tuples is $1+n+n+\binom{n}{2}+\binom{n}{2}=n^{2}+n+1$. For any two of them, at most two of the products $a_{i} b_{i}$ are non-zero. The only case in which two of them are non-zero is when we take a sequence $(*, 1, *, 1, *)$ and a sequence $(*, 1, *,-1, *)$ with zero entries in the same places. But in this case one $a_{i} b_{i}$ is 1 and the other -1 . This shows that any two of these sequences form an exquisite pair. Next, we claim that among any $n^{2}+n+2$ tuples, some two of them do not form an exquisite pair. We begin with lemma. Lemma. Given $2 n+1$ distinct non-zero $n$-tuples of real numbers, some two of them $\left(a_{1}, \ldots, a_{n}\right)$ and $\left(b_{1}, \ldots, b_{n}\right)$ satisfy $a_{1} b_{1}+\cdots+a_{n} b_{n}>0$. Proof of Lemma. We proceed by induction. The statement is easy for $n=1$ since for every three non-zero numbers there are two of them with the same sign. Assume that the statement is true for $n-1$ and consider $2 n+1$ tuples with $n$ entries. Since we are working with tuples of real numbers, we claim that we may assume that one of the tuples is $a=(0,0, \ldots, 0,-1)$. Let us postpone the proof of this claim for the moment. If one of the remaining tuples $b$ has a negative last entry, then $a$ and $b$ satisfy the desired condition. So we may assume all the remaining tuples has a non-negative last entry. Now, from each tuple remove the last number. If two $n$-tuples $b$ and $c$ yield the same $(n-1)$-tuple, then $$ b_{1} c_{1}+\cdots+b_{n-1} c_{n-1}+b_{n} c_{n}=b_{1}^{2}+\cdots+b_{n-1}^{2}+b_{n} c_{n}>0 $$ and we are done. The remaining case is that all the $n$-tuples yield distinct ( $n-1$ )-tuples. Then at most one of them is the zero $(n-1)$-tuple, and thus we can use the inductive hypothesis on $2 n-1$ of them. So we find $b$ and $c$ for which $$ \left(b_{1} c_{1}+\cdots+b_{n-1} c_{n-1}\right)+b_{n} c_{n}>0+b_{n} c_{n}>0 $$ The only thing that we are left to prove is that in the inductive step we may assume that one of the tuples is $a=(0,0, \ldots, 0,-1)$. Fix one of the tuples $x=\left(x_{1}, \ldots, x_{n}\right)$. Set a real number $\varphi$ for which $\tan \varphi=\frac{x_{1}}{x_{2}}$. Change each tuple $a=\left(a_{1}, a_{2}, \ldots, a_{n}\right)$ (including $x$ ), to the tuple $$ \left(a_{1} \cos \varphi-a_{2} \sin \varphi, a_{1} \sin \varphi+a_{2} \cos \varphi, a_{3}, a_{4}, \ldots, a_{n}\right) $$ A straightforward calculation shows that the first coordinate of the tuple $x$ becomes 0 , and that all the expressions of the form $a_{1} b_{1}+\cdots+a_{n} b_{n}$ are preserved. We may iterate this process until all the entries of $x$ except for the last one are equal to 0 . We finish by multiplying all the entries in all the tuples by a suitable constant that makes the last entry of $x$ equal to -1 . This preserves the sign of all the expressions of the form $a_{1} b_{1}+\cdots+a_{n} b_{n}$. We proceed to the proof of our claim. Let $A$ be a set of non-zero tuples among which any two form an exquisite pair. It suffices to prove that $|A| \leq n^{2}+n$. We can write $A$ as a disjoint union of subsets $A_{1} \cup A_{2} \cup \ldots \cup A_{n}$, where $A_{i}$ is the set of tuples in $A$ whose last non-zero entry appears in the $i$ th position. We will show that $\left|A_{i}\right| \leq 2 i$, which will finish our proof since $2+4+\cdots+2 n=n^{2}+n$. Proceeding by contradiction, suppose that $\left|A_{i}\right| \geq 2 i+1$. If $A_{i}$ has three or more tuples whose only non-zero entry is in the $i$ th position, then for two of them this entry has the same sign. Since the tuples are different and their entries are integers, this yields two tuples for which $\left|\sum a_{i} b_{i}\right| \geq 2$, a contradiction. So there are at most two such tuples. We remove them from $A_{i}$. Now, for each of the remaining tuples $a$, if it has a positive $i$ th coordinate, we keep $a$ as it is. If it has a negative $i$ th coordinate, we replace it with the opposite tuple $-a$ with entries with opposite signs. This does not changes the exquisite pairs condition. After making the necessary changes, we have two cases. The first case is that there are two tuples $a$ and $b$ that have the same first $i-1$ coordinates and thus $$ a_{1} b_{1}+\cdots+a_{i-1} b_{i-1}=a_{1}^{2}+\cdots+a_{i-1}^{2}>0 $$ and thus is at least 1 (the entries are integers). The second case is that no two tuples have the same first $i-1$ coordinates, but then by the Lemma we find two tuples $a$ and $b$ for which $$ a_{1} b_{1}+\cdots+a_{i-1} b_{i-1} \geq 1 $$ In any case, we obtain $$ a_{1} b_{1}+\cdots+a_{i-1} b_{i-1}+a_{i} b_{i} \geq 2 $$ This yields a final contradiction to the exquisite pair hypothesis.