problem: There are $a+b$ bowls arranged in a row, numbered 1 through $a+b$, where $a$ and $b$ are given positive integers. Initially, each of the first $a$ bowls contains an apple, and each of the last $b$ bowls contains a pear. A legal move consists of moving an apple from bowl $i$ to bowl $i+1$ and a pear from bowl $j$ to bowl $j-1$, provided that the difference $i-j$ is even. We permit multiple fruits in the same bowl at the same time. The goal is to end up with the first $b$ bowls each containing a pear and the last $a$ bowls each containing an apple. Show that this is possible if and only if the product $a b$ is even.

solution: First we show that if $a b$ is even then the goal is possible. We prove the result by induction on $a+b$.  - If $\min (a, b)=0$ there is nothing to check. - If $\min (a, b)=1$, say $a=1$, then $b$ is even, and we can swap the (only) leftmost apple with the rightmost pear by working only with those fruits. - Now assume $\min (a, b) \geq 2$ and $a+b$ is odd. Then we can swap the leftmost apple with rightmost pear by working only with those fruits, reducing to the situation of $(a-1, b-1)$ which is possible by induction (at least one of them is even). - Finally assume $\min (a, b) \geq 2$ and $a+b$ is even (i.e. $a$ and $b$ are both even). Then we can swap the apple in position 1 with the pear in position $a+b-1$, and the apple in position 2 with the pear in position $a+b$. This reduces to the situation of $(a-2, b-2)$ which is also possible by induction.  Now we show that the result is impossible if $a b$ is odd. Define  $$ \begin{aligned} & X=\text { number apples in odd-numbered bowls } \\ & Y=\text { number pears in odd-numbered bowls. } \end{aligned} $$  Note that $X-Y$ does not change under this operation. However, if $a$ and $b$ are odd, then we initially have $X=\frac{1}{2}(a+1)$ and $Y=\frac{1}{2}(b-1)$, while the target position has $X=\frac{1}{2}(a-1)$ and $Y=\frac{1}{2}(b+1)$. So when $a b$ is odd this is not possible.  First, note that apples only move right and pears only move left, a successful operation must take exactly $a b$ moves. So it is enough to prove that the number of moves made must be even.  However, the number of fruits in odd-numbered bowls either increases by +2 or -2 in each move (according to whether $i$ and $j$ are both even or both odd), and since it ends up being the same at the end, the number of moves must be even.  Alternatively, as pointed out in the official solutions, one can consider the sums of squares of positions of fruits. The quantity changes by  $$ \left[(i+1)^{2}+(j-1)^{2}\right]-\left(i^{2}+j^{2}\right)=2(i-j)+2 \equiv 2(\bmod 4) $$  at each step, and eventually the sums of squares returns to zero, as needed.


problem: For which pairs of integers $(a, b)$ do there exist functions $f: \mathbb{Z} \rightarrow \mathbb{Z}$ and $g: \mathbb{Z} \rightarrow \mathbb{Z}$ obeying  $$ f(g(x))=x+a \quad \text { and } \quad g(f(x))=x+b $$  for all integers $x$ ?

solution: The answer is if $a=b$ or $a=-b$. In the former case, one can take $f(x) \equiv x+a$ and $g(x) \equiv x$. In the latter case, one can take $f(x) \equiv-x+a$ and $g(x)=-x$.  Now we prove these are the only possibilities. First: Claim - The functions $f$ and $g$ are bijections.  Note also that for any $x$, we have  $$ \begin{aligned} & f(x+b)=f(g(f(x)))=f(x)+a \\ & g(x+a)=g(f(g(x)))=g(x)+b . \end{aligned} $$  If either $a$ is zero or $b$ is zero, we immediately get the other is zero, and hence done. So assume $a b \neq 0$.  If $|b|>|a|$, then two of  $$ \{f(0), f(1), \ldots, f(b-1)\} \quad(\bmod |a|) $$  coincide, which together with repeatedly applying the first equation above will then give a contradiction to injectivity of $f$. Similarly, if $|a|>|b|$ swapping the roles of $f$ and $g$ (and $a$ and $b$ ) will give a contradiction to injectivity of $g$. This completes the proof.  Remark. Here is a way to visualize the argument, so one can see pictorially what is going on. We draw two parallel number lines indexed by $\mathbb{Z}$. Starting from 0 , we draw red arrow from 0 to $f(0)$, and then a blue arrow from $f(0)$ to $g(f(0))=b$, and then a red arrow from $b$ to $g(b)=f(0)+a$, and so on. These arrows can be extended both directions, leading to an infinite "squaretooth" wave. The following is a picture of an example with $a, b>0$. ![](https://cdn.mathpix.com/cropped/2024_11_19_10fe2e18e797a050a222g-05.jpg?height=358&width=1112&top_left_y=2134&top_left_x=478)  The problem is essentially trying to decompose our two copies of $\mathbb{Z}$ into multiple squaretooth waves. For this to be possible, we expect the "width" of the waves on the top and bottom must be the same - i.e., that $|a|=|b|$.  Remark. This also suggests how to classify all functions $f$ and $g$ satisfying the condition. If $a=b=0$ then any pair of functions $f$ and $g$ which are inverses to each other is okay. There are thus uncountably many pairs of functions $(f, g)$ here.  If $a=b>0$, then one sets $f(0), f(1), \ldots, f(a-1)$ as any values which are distinct modulo $b$, at which point $f$ and $g$ are uniquely determined. An example for $a=b=3$ is  $$ f(x)=\left\{\begin{array}{lll} x+42 & x \equiv 0 & (\bmod 3) \\ x+13 & x \equiv 1 & (\bmod 3) \\ x-37 & x \equiv 2 & (\bmod 3), \end{array} \quad g(x)=\left\{\begin{array}{lll} x-39 & x \equiv 0 & (\bmod 3) \\ x+40 & x \equiv 1 & (\bmod 3) \\ x-10 & x \equiv 2 & (\bmod 3) \end{array}\right.\right. $$  The analysis for $a=b<0$ and $a=-b$ are similar, but we don't include the details here.


problem: Let $A B C D$ be a cyclic quadrilateral satisfying $A D^{2}+B C^{2}=A B^{2}$. The diagonals of $A B C D$ intersect at $E$. Let $P$ be a point on side $\overline{A B}$ satisfying $\angle A P D=\angle B P C$. Show that line $P E$ bisects $\overline{C D}$.

solution: 【 First solution using symmedians. We define point $P$ to obey  $$ \frac{A P}{B P}=\frac{A D^{2}}{B C^{2}}=\frac{A E^{2}}{B E^{2}} $$  so that $\overline{P E}$ is the $E$-symmedian of $\triangle E A B$, therefore the $E$-median of $\triangle E C D$. Now, note that  $$ A D^{2}=A P \cdot A B \quad \text { and } \quad B C^{2}=B P \cdot B A $$  This implies $\triangle A P D \sim \triangle A D B$ and $\triangle B P C \sim \triangle B C A$. Thus  $$ \measuredangle D P A=\measuredangle A D B=\measuredangle A C B=\measuredangle B C P $$  and so $P$ satisfies the condition as in the statement (and is the unique point to do so), as needed.


solution: 【 Second solution using only angle chasing (by proposer). We again re-define $P$ to obey $A D^{2}=A P \cdot A B$ and $B C^{2}=B P \cdot B A$. As before, this gives $\triangle A P D \sim \triangle A B D$ and $\triangle B P C \sim \triangle B D P$ and so we let  $$ \theta:=\measuredangle D P A=\measuredangle A D B=\measuredangle A C B=\measuredangle B C P . $$  Our goal is to now show $\overline{P E}$ bisects $\overline{C D}$. Let $K=\overline{A C} \cap \overline{P D}$ and $L=\overline{A D} \cap \overline{P C}$. Since $\measuredangle K P A=\theta=\measuredangle A C B$, quadrilateral $B P K C$ is cyclic. Similarly, so is $A P L D$. ![](https://cdn.mathpix.com/cropped/2024_11_19_10fe2e18e797a050a222g-08.jpg?height=804&width=795&top_left_y=246&top_left_x=633)  Finally $A K L B$ is cyclic since  $$ \measuredangle B K A=\measuredangle B K C=\measuredangle B P C=\theta=\measuredangle D P A=\measuredangle D L A=\measuredangle B L A . $$  This implies $\measuredangle C K L=\measuredangle L B A=\measuredangle D C K$, so $\overline{K L} \| \overline{B C}$. Then $P E$ bisects $\overline{B C}$ by Ceva's theorem on $\triangle P C D$.


solution: 【 Third solution (using inversion). By hypothesis, the circle $\omega_{a}$ centered at $A$ with radius $A D$ is orthogonal to the circle $\omega_{b}$ centered at $B$ with radius $B C$. For brevity, we let $\mathbf{I}_{a}$ and $\mathbf{I}_{b}$ denote inversion with respect to $\omega_{a}$ and $\omega_{b}$. We let $P$ denote the intersection of $\overline{A B}$ with the radical axis of $\omega_{a}$ and $\omega_{b}$; hence $P=\mathbf{I}_{a}(B)=\mathbf{I}_{b}(A)$. This already implies that  $$ \measuredangle D P A \stackrel{\mathbf{I}_{a}}{=} \measuredangle A D B=\measuredangle A C B \stackrel{\mathbf{I}_{b}}{=} \measuredangle B P C $$  so $P$ satisfies the angle condition. ![](https://cdn.mathpix.com/cropped/2024_11_19_10fe2e18e797a050a222g-08.jpg?height=732&width=1012&top_left_y=1844&top_left_x=522)  Claim - The point $K=\mathbf{I}_{a}(C)$ lies on $\omega_{b}$ and $\overline{D P}$. Similarly $L=\mathbf{I}_{b}(D)$ lies on $\omega_{a}$ and $\overline{C P}$.   Finally, since $C, L, P$ are collinear, we get $A$ is concyclic with $K=\mathbf{I}_{a}(C), L=\mathbf{I}_{a}(L)$, $B=\mathbf{I}_{a}(P)$, i.e. that $A K L B$ is cyclic. So $\overline{K L} \| \overline{C D}$ by Reim's theorem, and hence $\overline{P E}$ bisects $\overline{C D}$ by Ceva's theorem.


problem: Let $A B C$ be a triangle with $\angle B>90^{\circ}$ and let $E$ and $F$ be the feet of the altitudes from $B$ and $C$. Can line $E F$ be tangent to the $A$-excircle?

solution: We show it is not possible, by contradiction (assuming $E F$ is indeed tangent). Thus $B E C F$ is a convex cyclic quadrilateral inscribed in a circle with diameter $\overline{B C}$. Note also that the $A$-excircle lies on the opposite side from $A$ as line $E F$, since $A, E, C$ are collinear in that order. 【 First solution by similarity. Note that $\triangle A E F$ is similar to $\triangle A B C$ (and oppositely oriented). However, since they have the same $A$-exradius, it follows they are congruent. ![](https://cdn.mathpix.com/cropped/2024_11_19_10fe2e18e797a050a222g-10.jpg?height=272&width=621&top_left_y=1195&top_left_x=729)  Consequently we get $E F=B C$. But this implies $B F C E$ is a rectangle, contradiction.


solution: We show it is not possible, by contradiction (assuming $E F$ is indeed tangent). Thus $B E C F$ is a convex cyclic quadrilateral inscribed in a circle with diameter $\overline{B C}$. Note also that the $A$-excircle lies on the opposite side from $A$ as line $E F$, since $A, E, C$ are collinear in that order. 【 Second length solution by tangent lengths. By $t(\bullet)$ we mean the length of the tangent from $P$ to the $A$-excircle. It is a classical fact for example that $t(A)=s$. The main idea is to use the fact that  $$ a \cos A=E F=t(E)+t(F) . $$  Here $E F=a \cos A$ follows from the extended law of sines applied to the circle with diameter $\overline{B C}$, since there we have $E F=B C \sin \angle E C F=a \sin \angle A C F=a \cos A$. We may now compute  $$ \begin{aligned} & t(E)=t(A)-A E=s-c \cos A \\ & t(F)=t(A)-A F=s-b \cos A \end{aligned} $$  Therefore,  $$ \begin{aligned} a \cos A=2 s-(b+c) \cos A \Longrightarrow \quad(a+b+c) \cos A & =2 s \\ \Longrightarrow \cos A & =1 . \end{aligned} $$  This is an obvious contradiction. Remark. On the other hand, there really is an equality case with $A$ being some point at infinity (meaning $\cos A=1$ ). So, this problem is "sharper" than one might expect; the answer is not "obviously no".


solution: We show it is not possible, by contradiction (assuming $E F$ is indeed tangent). Thus $B E C F$ is a convex cyclic quadrilateral inscribed in a circle with diameter $\overline{B C}$. Note also that the $A$-excircle lies on the opposite side from $A$ as line $E F$, since $A, E, C$ are collinear in that order. I Third solution by Pitot and trigonometry. In fact, the $t(\bullet)$ notation from the previous solution gives us a classical theorem once we note the $A$-excircle is tangent to all four lines $E F, B C, B F$ and $C E$ :  Claim (Pitot theorem) - We have $B F+E F=B C+C E$.   $$ \begin{array}{ll} B F=t(B)-t(F) & E F=t(E)+t(F) \\ B C=t(B)+t(C) & C E=t(E)-t(C) \end{array} $$  and summing gives the result. ![](https://cdn.mathpix.com/cropped/2024_11_19_10fe2e18e797a050a222g-11.jpg?height=809&width=686&top_left_y=995&top_left_x=685)  We now calculate all the lengths using trigonometry:  $$ \begin{aligned} & B C=a \\ & B F=a \cos \left(180^{\circ}-B\right)=a \cos (A+C) \\ & C E=a \cos C \\ & E F=B C \sin \angle E C F=a \sin \angle A C F=a \cos A \end{aligned} $$  Thus, we apparently have  $$ \cos (A+C)+\cos A=1+\cos C $$  but this is impossible since $\cos (A+C)<\cos C$ (since $A+C=180-B<90^{\circ}$ ) and $\cos A<1$.


solution: We show it is not possible, by contradiction (assuming $E F$ is indeed tangent). Thus $B E C F$ is a convex cyclic quadrilateral inscribed in a circle with diameter $\overline{B C}$. Note also that the $A$-excircle lies on the opposite side from $A$ as line $E F$, since $A, E, C$ are collinear in that order. 【 Fourth solution by Pitot and Ptolemy (Evan Chen). We give a trig-free way to finish from Pitot's theorem  $$ B F+E F=B C+C E . $$  Assume that $x=B F, y=C E$, and $B C=1$; then the above relation becomes  $$ 1+y-x=B C+C E-B F=E F=E F \cdot 1=x y+\sqrt{\left(1-x^{2}\right)\left(1-y^{2}\right)} $$  with the last step by Ptolemy's theorem. This rearranges to give  $$ (1+y)(1-x)=\sqrt{\left(1-x^{2}\right)\left(1-y^{2}\right)} \Longrightarrow \frac{1+y}{1-y}=\frac{1+x}{1-x} \Longrightarrow x=y $$  but that means $B E C F$ is a rectangle: contradicting the fact that lines $B E$ and $C F$ meet at a point $A$.


solution: We show it is not possible, by contradiction (assuming $E F$ is indeed tangent). Thus $B E C F$ is a convex cyclic quadrilateral inscribed in a circle with diameter $\overline{B C}$. Note also that the $A$-excircle lies on the opposite side from $A$ as line $E F$, since $A, E, C$ are collinear in that order. 『 Fifth solution, by angle chasing only! Let $J$ denote the $A$-excenter. Then $J$ should be the intersection of the internal bisectors of $\angle F E C$ and $\angle F B C$, so it is the midpoint of arc $\widehat{F C}$ on the circle with diameter $\overline{B C}$. ![](https://cdn.mathpix.com/cropped/2024_11_19_10fe2e18e797a050a222g-12.jpg?height=824&width=690&top_left_y=1093&top_left_x=683)  But now we get $\angle B J C=90^{\circ}$ from $J$ lying on this circle. Yet $\angle B J C=90^{\circ}-\frac{1}{2} \angle A$ in general, so $\angle A=0^{\circ}$ which is impossible.


solution: We show it is not possible, by contradiction (assuming $E F$ is indeed tangent). Thus $B E C F$ is a convex cyclic quadrilateral inscribed in a circle with diameter $\overline{B C}$. Note also that the $A$-excircle lies on the opposite side from $A$ as line $E F$, since $A, E, C$ are collinear in that order. 【 Sixth solution (Zuming Feng). This is similar to the preceding solution, but phrased using contradiction and inequalities. We let $X$ and $Y$ denote the tangency points of the $A$-excircle on lines $A B$ and $A C$. Moreover, let $J$ denote the $A$-excenter. ![](https://cdn.mathpix.com/cropped/2024_11_19_10fe2e18e797a050a222g-12.jpg?height=350&width=809&top_left_y=2275&top_left_x=635)  Note that $A B>A E$ and $A X=A Y$, therefore $B X<E Y$. By considering the right triangles $X B J$ and $Y E J$ (which both have $J X=J Y$ ), we conclude $\tan \angle X B J>$ $\tan \angle Y E J$, thus  $$ \angle X B J>\angle Y E J $$  However, if line $E F$ was actually tangent to the $A$-excircle, we would have  $$ 2 \angle X B J=\angle X B C=\angle F B C=\angle F E C=\angle F E Y=2 \angle J E Y $$  which is a contradiction.


solution: We show it is not possible, by contradiction (assuming $E F$ is indeed tangent). Thus $B E C F$ is a convex cyclic quadrilateral inscribed in a circle with diameter $\overline{B C}$. Note also that the $A$-excircle lies on the opposite side from $A$ as line $E F$, since $A, E, C$ are collinear in that order. 【 Seventh solution, by complex numbers, for comedic effect (Evan Chen). Let us denote the tangency points of the $A$-excircle with sides $B C, C A, A B$ as $x, y, z$. Assume moreover that line $E F$ is tangent to the $A$-excircle at a point $P$.  Also, for brevity let $s=x y+y z+z x$. Then, we have  $$ \begin{aligned} & E=\frac{2 p y}{p+y}=\frac{1}{2}\left(b+y+y-y^{2} \bar{b}\right)=\frac{z x}{z+x}+y-\frac{y^{2}}{z+x} \\ & \Longrightarrow \frac{2}{\frac{1}{p}+\frac{1}{y}}=\frac{x y+x z+z x-y^{2}}{z+x} \Longrightarrow \frac{\frac{1}{p}+\frac{1}{y}}{2}=\frac{x+z}{s-y^{2}} \end{aligned} $$  Similarly by considering the point $F$,  $$ \frac{\frac{1}{p}+\frac{1}{z}}{2}=\frac{x+y}{s-z^{2}} $$  Thus we can eliminate $P$ and obtain  $$ \begin{aligned} \Longrightarrow \frac{\frac{1}{y}-\frac{1}{z}}{2} & =\frac{x+z}{s-y^{2}}-\frac{x+y}{s-z^{2}}=\frac{-s(y-z)+x\left(y^{2}-z^{2}\right)+\left(y^{3}-z^{3}\right)}{\left(s-y^{2}\right)\left(s-z^{2}\right)} \\ \Longleftrightarrow \frac{1}{2 y z} & =\frac{s-x(y+z)-\left(y^{2}+y z+z^{2}\right)}{\left(s-y^{2}\right)\left(s-z^{2}\right)}=\frac{-\left(y^{2}+z^{2}\right)}{\left(s-y^{2}\right)\left(s-z^{2}\right)} \\ \Longleftrightarrow 0 & =\left(s-y^{2}\right)\left(s-z^{2}\right)+2 y z\left(y^{2}+z^{2}\right) \\ & =[x(y+z)+y(z-y)][x(y+z)+z(y-z)]+2 y z\left(y^{2}+z^{2}\right) \\ & =x^{2}(y+z)^{2}-(y-z)^{2} \cdot x(y+z)+y z\left(2 y^{2}+2 z^{2}-(y-z)^{2}\right) \\ & =x^{2}(y+z)^{2}-(y-z)^{2} \cdot x(y+z)+y z(y+z)^{2} \\ & =x y z(y+z)\left[\frac{x}{y}+\frac{x}{z}-\frac{y}{z}-\frac{z}{y}+2+\frac{y}{x}+\frac{z}{x}\right] \end{aligned} $$  However, $\triangle X Y Z$ is obtuse with $\angle X>90^{\circ}$, we have $y+z \neq 0$. Note that  $$ \begin{aligned} & \frac{x}{y}+\frac{y}{x}=2 \operatorname{Re} \frac{x}{y}=2 \cos (2 \angle X Z Y) \\ & \frac{x}{z}+\frac{z}{x}=2 \operatorname{Re} \frac{x}{z}=2 \cos (2 \angle X Y Z) \\ & \frac{y}{z}+\frac{z}{y}=2 \operatorname{Re} \frac{y}{z}<2 \end{aligned} $$  and since $\cos (2 \angle X Z Y)+\cos (2 \angle X Y Z)>0$ (say by sum-to-product), we are done.


problem: Let $n$ be a nonnegative integer. Determine the number of ways to choose sets $S_{i j} \subseteq\{1,2, \ldots, 2 n\}$, for all $0 \leq i \leq n$ and $0 \leq j \leq n$ (not necessarily distinct), such that  - $\left|S_{i j}\right|=i+j$, and - $S_{i j} \subseteq S_{k l}$ if $0 \leq i \leq k \leq n$ and $0 \leq j \leq l \leq n$.

solution: The answer is $(2 n)!\cdot 2^{n^{2}}$. First, we note that $\varnothing=S_{00} \subsetneq S_{01} \subsetneq \cdots \subsetneq S_{n n}=\{1, \ldots, 2 n\}$ and thus multiplying by (2n)! we may as well assume $S_{0 i}=\{1, \ldots, i\}$ and $S_{i n}=\{1, \ldots, n+i\}$. We illustrate this situation by placing the sets in a grid, as below for $n=4$; our goal is to fill in the rest of the grid. $\left[\begin{array}{ccccc}1234 & 12345 & 123456 & 1234567 & 12345678 \\ 123 & & & & \\ 12 & & & & \\ 1 & & & & \\ \varnothing & & & & \end{array}\right]$  We claim the number of ways to do so is $2^{n^{2}}$. In fact, more strongly even the partial fillings are given exactly by powers of 2 .  Claim - Fix a choice $T$ of cells we wish to fill in, such that whenever a cell is in $T$, so are all the cells above and left of it. (In other words, $T$ is a Young tableau.) The number of ways to fill in these cells with sets satisfying the inclusion conditions is $2^{|T|}$.  An example is shown below, with an indeterminate set marked in red (and the rest of $T$ marked in blue). $\left[\begin{array}{ccccc}1234 & 12345 & 123456 & 1234567 & 12345678 \\ 123 & 1234 & 12346 & 123467 & \\ 12 & 124 & 1234 \text { or } 1246 & & \\ 1 & 12 & & & \\ \varnothing & 2 & & & \end{array}\right]$  Now suppose we have a corner $\left[\begin{array}{cc}B & C \\ A & S\end{array}\right]$ where $A, B, C$ are fixed and $S$ is to be chosen. Then we may write $B=A \cup\{x\}$ and $C=A \cup\{x, y\}$ for $x, y \notin A$. Then the two choices of $S$ are $A \cup\{x\}$ (i.e. $B$ ) and $A \cup\{y\}$, and both of them are seen to be valid.  In this way, we gain a factor of 2 any time we add one cell as above to $T$. Since we can achieve any Young tableau in this way, the induction is complete.


problem: Let $m$ and $n$ be relatively prime positive integers. The numbers $\frac{m}{n}$ and $\frac{n}{m}$ are written on a blackboard. At any point, Evan may pick two of the numbers $x$ and $y$ written on the board and write either their arithmetic mean $\frac{1}{2}(x+y)$ or their harmonic mean $\frac{2 x y}{x+y}$. For which $(m, n)$ can Evan write 1 on the board in finitely many steps?

solution: We claim this is possible if and only $m+n$ is a power of 2 . Let $q=m / n$, so the numbers on the board are $q$ and $1 / q$. \I Impossibility. The main idea is the following. Claim - Suppose $p$ is an odd prime. Then if the initial numbers on the board are $-1(\bmod p)$, then all numbers on the board are $-1(\bmod p)$.   Thus if there exists any odd prime divisor $p$ of $m+n$ (implying $p \nmid m n$ ), then  $$ q \equiv \frac{1}{q} \equiv-1 \quad(\bmod p) . $$  and hence all numbers will be $-1(\bmod p)$ forever. This implies that it's impossible to write 1 , whenever $m+n$ is divisible by some odd prime.  【 Construction. Conversely, suppose $m+n$ is a power of 2 . We will actually construct 1 without even using the harmonic mean. ![](https://cdn.mathpix.com/cropped/2024_11_19_10fe2e18e797a050a222g-15.jpg?height=152&width=1004&top_left_y=1786&top_left_x=526)  Note that  $$ \frac{n}{m+n} \cdot q+\frac{m}{m+n} \cdot \frac{1}{q}=1 $$  and obviously by taking appropriate midpoints (in a binary fashion) we can achieve this using arithmetic mean alone.