# 2005 USAMO Problems/Problem 4

## Problem

(Elgin Johnston) Legs $L_1, L_2, L_3, L_4$ of a square table each have length $n$, where $n$ is a positive integer. For how many ordered 4-tuples $(k_1, k_2, k_3, k_4)$ of nonnegative integers can we cut a piece of length $k_i$ from the end of leg $L_i \; (i = 1,2,3,4)$ and still have a stable table?

(The table is stable if it can be placed so that all four of the leg ends touch the floor. Note that a cut leg of length 0 is permitted.)

## Solution 1

First flip the table upside down and observer the plane that the ends of the legs form. Let this plane be $ax+by+c=z$. Assume WLOG that the table is the square with endpoints $(0,0), (0,1), (1,0), (0,1)$ on the xy plane. Thus the lengths of the legs will be $c, c+b, c+a, c+a+b$ respectively. In other words $k_1+k_3=k_2+k_4=x$ for some $0 \le x \le 2n$.

For $0 \le x \le n$, it is easy to see that the number of stable tables is $(x+1)^2$.

For $n+1 \le x \le 2n$, we can biject the stable tables of $x$ to the stable of $2n-x$ by replacing all of the legs with the cut off portions.

So the total number of stable tables is $1^2+2^2+...+n^2+(n+1)^2+n^2+...+2^2+1^2 =$ $(1^2+2^2+...+(n+1)^2)+(1^2+2^2+...+n^2) =$ $\dfrac{(n+1)(n+2)(2n+3)}{6}+\dfrac{n(n+1)(2n+1)}{6}=\boxed{\dfrac{2n^3+6n^2+7n+3}{3}}$.

### Solution 2

Let $C_i$ be the number of sets of cuts $\{k_1,k_2,k_3,k_4\}$ that result in the longest leg being of length $i$. Then $C_i=C_{i-1}+x$, and we will evaluate $x$ to develop a recursion. Note that if a set of cuts has non-zero cuts, then if that set is counted in $C_i$, subtract $1$ from each of the cuts to obtain a set of cuts that is counted in $C_{i-1}$. For example, if $\{2,3,4,5\}$ was counted in $C_5$, then $\{1,2,3,4\}$ would have been counted in $C_4$ because subtracting the same length from each leg preserves the quality of the legs being coplanar, and there is a bijection.

Now we must evaluate those sets of cuts that don't fall in this bijection, which are clearly those where one leg is completely cut off. After some simple geometric reasoning that I won't include here, we see that one corner has a leg of length of zero, and the opposite leg, called the initial leg, will have length $i$ If the remaining legs have length $y$ and $z$, then $(y,z)=(0,i),(1,i-1),...,(i-1,1),(i,0)$, so $i+1$ options. The initial corner can be any of the four legs, but each of the four permutations of the set of cuts ${0,0,i,i}$ is repeated twice, so we have $4(i+1)-4=4i$ total additional sets of cuts. We conclude that $C_i=C_{i-1}+4i$, and note that $C_0=1$. Now we can create generating functions. $F(x)=\sum_{i=0}^\infty C_ix^i$. Also, $G(x)=\sum_{i=1}^\infty 4ix^i$. From the recursion, we have $$F(x)=C_0+xF(x)+G(x)\Longrightarrow F(x)=\frac{1+G(x)}{1-x}$$ This final equation is easy to analyze. Simply use $G(x)$ as the first term of a geometric series with constant multiplier of $x$. This gives $C_i=2i^2+2i+1$. The total number of sets of cuts for a table of legs of length $n$ is the sum of all the $C_i$, $0\le i\le n$, from which we deduce the answer $\frac{2n^3 + 6n^2 +7n + 3}{3}$, or $\frac{(n+1)(2n^2 + 4n +3)}{3}$.

### Solution 3

The problem's condition is that the ends of the legs must be coplanar. So the plane formed by legs $L_1$, $L_2$, and $L_3$ is the same as the plane formed by the legs $L_2$, $L_3$, and $L_4$ iff the problem's condition is met.

We now assign coordinates to the ends of the legs. Let the table be on the xy-plane such that $L_1$ is at $(0,0,k_1)$, $L_2$ is at $(s,0,k_2)$, $L_3$ is at $(0,s,k_3)$, and $L_4$ is at $(s,s,k_4)$, where $s$ is the side length of the table. (Note that we have turned the table over so that the top lies on the xy plane while the legs point in the +z direction - this does not affect the result.) A plane in 3-space has the equation form $Ax+By+Cz=1$. Plugging the coordinates of $L_1$, $L_2$, and $L_3$ into $Ax+By+Cz=1$, we eventually get $A_1=\dfrac{k_1-k_2}{sk_1}$, $B_1=\dfrac{k_1-k_3}{sk_1}$, $C_1=\dfrac{1}{k_1}$. Plugging the coordinates of $L_2$, $L_3$, and $L_4$ into $Ax+By+Cz=1$, we get $A_2=\dfrac{k_3-k_4}{s(k_2+k_3-k_4)}$, $B_2=\dfrac{k_2-k_4}{s(k_2+k_3-k_4)}$, $C_2=\dfrac{1}{k_2+k_3-k_4}$.

Since we need these to be coplanar, we set $A_1=A_2$, $B_1=B_2$, and $C_1=C_2$. (Notice that the $s$'s cancel.) From $A_1=A_2$, we get $(k_1-k_2)(k_2+k_3-k_4)=k_1(k_3-k_4)$ [1]. From $B_1=B_2$, we get $(k_1-k_3)(k_2+k_3-k_4)=k_1(k_2-k_4)$ [2]. From $C_1=C_2$, we get $k_1=k_2+k_3-k_4$ [3]. Notice that [1] and [2] can both be obtained directly from [3] and are therefore redundant. The only condition we have left to ensure that the ends of the legs are coplanar is $k_1+k_4=k_2+k_3$. Let $k_1+k_4=k_2+k_3=m$.

We proceed using casework by $m$. $m$ is an integer between $0$ and $2n$, inclusive. Furthermore, we note that $k_i$ range from $0$ to $n$, inclusive. For $m=0$, each of $(k_1,k_4)$ and $(k_2,k_3)$ have one choice, $(0,0)$. For $m=1$, they each have two choices, $(0,1)$ and $(1,0)$. And so on, until $m=n$, where they each have $n+1$ choices: $(0,n),(1,n-1),\cdots,(n-1,1),(n,0)$. When $m=n+1$, the restriction that $0\le k_i\le n$ takes effect: there are only $n$ choices for each ordered pair, which are $(1,n),(2,n-1),\cdots,(n-1,2),(n,1)$. And so on, until $m=2n$, where there is one choice for each ordered pair, $(n,n)$.

The number of possible 4-tuples $(k_1,k_2,k_3,k_4)$ is thus $1^2+2^2+...+n^2+(n+1)^2+n^2+...+2^2+1^2$, which is equivalent to $(1^2+2^2+...+(n+1)^2)+(1^2+2^2+...+n^2)$. Our final answer is $\dfrac{(n+1)(n+2)(2n+3)}{6}+\dfrac{n(n+1)(2n+1)}{6}=\boxed{\dfrac{2n^3+6n^2+7n+3}{3}}$.

Alternate solutions are always welcome. If you have a different, elegant solution to this problem, please add it to this page.