Maths Olympiad Prep

Track / Stage 9 / 16 of 52 #2536 of 2604

Problem 2536

IMO P2/P5; hard shortlist
Combinatorics Difficulty 9.2 Prove it USA IMO · United States

Let nn be a positive integer. Consider sequences a0,a1,…,ana_0, a_1, \dots, a_n such that ai∈{1,2,…,n}a_i \in \{1, 2, \dots, n\} for each ii and an=a0a_n = a_0.

a. Call such a sequence good if for all i=1,2,…,ni = 1, 2, \dots, n, ai−ai−1≢i(modn)a_i - a_{i-1} \not\equiv i \pmod n. Suppose that nn is odd. Find the number of good sequences.

b. Call such a sequence great if for all i=1,2,…,ni = 1, 2, \dots, n, ai−ai−1≢i,2i(modn)a_i - a_{i-1} \not\equiv i, 2i \pmod n. Suppose that nn is an odd prime. Find the number of great sequences.

This one wants a proof. Work it on paper, then read the official solution and mark yourself. Be honest about it: the record is only any use to you if it is.

Next problem →

Official solution

First Solution: The answer is (n−1)n−(n−1)(n-1)^n - (n-1) for part (a) and (n−1)((n−2)n−1−1)(n-1)((n-2)^{n-1} - 1) for part (b).

a. Observe that the number of good sequences is clearly the same for any choice of a0a_0. For fixed a0a_0, call the condition ai−ai−1≢i(modn)a_i - a_{i-1} \not\equiv i \pmod n condition (i). Now let SiS_i be the set of sequences A={ai}i=1n,ai∈{1,2,…,n}A = \{a_i\}_{i=1}^n, a_i \in \{1, 2, \dots, n\} such that AA satisfies conditions (1), (2), …,\dots, (n−i)(n-i) and fails to satisfy conditions (n−i+2)(n-i+2), (n−i+3)(n-i+3), …,\dots, (n)(n). Note that there is no constraint on whether or not AA satisfies condition (n−i+1)(n-i+1). Finally, let FF be the set of sequences that fails all conditions (1), (2), …,\dots, (n)(n). Then we claim that the number of good sequences starting with a0a_0 is
m=∣S1∣−∣S2∣+∣S3∣−⋯+∣Sn∣−∣F∣. m = |S_1| - |S_2| + |S_3| - \dots + |S_n| - |F|.
Consider the following table, representing the conditions on sequences in SiS_i.
S1(1)(2)(3)…(n−2)(n−1)S2(1)(2)(3)…(n−2)(n)‾S3(1)(2)(3)…(n−1)‾(n)‾⋮⋮⋮⋮…⋮⋮⋮Sn(2)‾(3)‾…(n−2)‾(n−1)‾(n)‾F(1)(2)(3)…(n−2)‾(n−1)‾(n)‾ \begin{array}{c|ccccccc} S_1 & (1) & (2) & (3) & \dots & (n-2) & (n-1) & \\ \hline S_2 & (1) & (2) & (3) & \dots & (n-2) & \overline{(n)} & \\ \hline S_3 & (1) & (2) & (3) & \dots & \overline{(n-1)} & \overline{(n)} & \\ \hline \vdots & \vdots & \vdots & \vdots & \dots & \vdots & \vdots & \vdots \\ \hline S_n & \overline{(2)} & \overline{(3)} & \dots & \overline{(n-2)} & \overline{(n-1)} & \overline{(n)} & \\ \hline F & (1) & (2) & (3) & \dots & \overline{(n-2)} & \overline{(n-1)} & \overline{(n)} \end{array}
Conditions that appear as (j)(j) in row ii are satisfied by sequences in SiS_i, and those that appear as (j)‾\overline{(j)} are failed.

Now take any sequence AA. If AA is good, then AA is counted exactly once in ∣S1∣|S_1| and is not counted anywhere else. Otherwise, if AA is not good, let (i)(i) be the first condition that AA fails. If i>1i > 1, then AA belongs to exactly the sets Sn−1,Sn−2S_{n-1}, S_{n-2}. As one of ∣Sn−1∣,∣Sn−2∣|S_{n-1}|, |S_{n-2}| is added and one is subtracted, AA has no net contribution to mm. Finally, if i=1i = 1, then AA belongs to SnS_n and FF, so again AA does not contribute to mm. Therefore, mm is indeed the number of good sequences.

We are left with computing the sizes of the SiS_i's and FF. This is easy, as the failure of the final i−1i-1 conditions determines the terms an−1,an−2,…,an−i+1a_{n-1}, a_{n-2}, \dots, a_{n-i+1}, whereas there are just n−1n-1 ways to satisfy each of the conditions (1), (2), …,\dots, (n−i)(n-i), producing (n−1)n−i(n-1)^{n-i} subsequences a0,a1,…,an−ia_0, a_1, \dots, a_{n-i}. As there is no constraint on an−i+1−an−ia_{n-i+1} - a_{n-i}, we have found all sequences in SiS_i. Hence, ∣Si∣=(n−1)n−i|S_i| = (n-1)^{n-i}. As for FF, there is clearly exactly one way to fail every single condition, because 1+2+⋯+(n−1)=n(n−1)21+2+\dots+(n-1) = \frac{n(n-1)}{2} is divisible by nn. Therefore, ∣Sn∣−F=0|S_n| - F = 0 and
m=∣S1∣−∣S2∣+⋯−∣Sn−1∣=(n−1)n−1−(n−1)n−2+⋯−(n−1)=(n−1)n−(n−1)n. \begin{align*} m &= |S_1| - |S_2| + \dots - |S_{n-1}| \\ &= (n-1)^{n-1} - (n-1)^{n-2} + \dots - (n-1) \\ &= \frac{(n-1)^n - (n-1)}{n}. \end{align*}
As there were originally nn choices for a0a_0, multiplying by nn gives the desired answer.

b. We can use the same argument as in part (a), but we must recompute the values of ∣Si∣|S_i| and ∣F∣|F|. Note that for 1≤i≤n−11 \le i \le n-1, there are exactly two ways to fail condition (i) (because nn is odd) while condition (n) is degenerate and reduces to the single restriction an−an−1≢0(modn)a_n - a_{n-1} \not\equiv 0 \pmod{n}. Hence, we have
∣S1∣=(n−2)n−1and∣Si∣=2i−2(n−2)n−i, |S_1| = (n-2)^{n-1} \quad \text{and} \quad |S_i| = 2^{i-2}(n-2)^{n-i},
for 2≤i≤n2 \le i \le n. Finding ∣F∣|F| is trickier in this case, however. Considering the differences bi=ai−ai−1b_i = a_i - a_{i-1}, i=1,2,…,ni = 1, 2, \dots, n, we wish to count the number of choices of {bi}i=1n\{b_i\}_{i=1}^n such that
b1+b2+⋯+bn≡0(modn), b_1 + b_2 + \dots + b_n \equiv 0 \pmod{n},
where bi=ib_i = i or 2i(modn)2i \pmod{n} for each ii. Note that because of the degenerate condition (n)(n), bn≡0(modn)b_n \equiv 0 \pmod{n} is forced; hence, we are actually looking at 2n−12^{n-1} sums b1+b2+⋯+bn−1b_1 + b_2 + \dots + b_{n-1} rather than 2n2^n. Now, as n∣[1+2+⋯+(n−1)]=n(n−1)2n \mid [1 + 2 + \dots + (n-1)] = \frac{n(n-1)}{2}, we can equivalently consider sums of terms ci=bi−ic_i = b_i - i. That is, we wish to find the number of choices of c1,c2,…,cn−1c_1, c_2, \dots, c_{n-1} such that
c1+c2+⋯+cn−1≡0(modn), c_1 + c_2 + \dots + c_{n-1} \equiv 0 \pmod{n},
where ci=0c_i = 0 or ii for each ii. We now introduce an extra term cnc_n that can be either 0 or nn. The only effect of this extra term is to double the number of choices of {ci}i=1n\{c_i\}_{i=1}^n compared to the number of choices of {ci}i=1n−1\{c_i\}_{i=1}^{n-1}. That is, letting
F′={(c1,c2,…,cn)∣[t]ci=0 or i,c1+c2+⋯+cn≡0(modn)}, F' = \{(c_1, c_2, \dots, c_n) \mid \begin{aligned}[t] & c_i = 0 \text{ or } i, \\ & c_1 + c_2 + \dots + c_n \equiv 0 \pmod{n} \end{aligned}\},
we have ∣F∣=12∣F′∣|F| = \frac{1}{2}|F'|.

Observe that we can identify choices (c1,c2,…,cn)(c_1, c_2, \dots, c_n) with subsets of T={1,2,…,n}T = \{1, 2, \dots, n\}; the elements of F′F' are then simply the subsets of TT that have sum divisible by nn. The empty set and the set TT are two sets that clearly satisfy this property. All remaining subsets U⊂TU \subset T have from 1 to n−1n-1 elements. Write U+kU+k for the set {x+k∣x∈U}\{x+k \mid x \in U\} (taken mod nn); this is the rotation of UU by kk shifts to the right. Then because nn is prime and 0<∣U∣<n0 < |U| < n, the subsets U,U+1,U+2,…,U+(n−1)U, U+1, U+2, \dots, U+(n-1) form an equivalence class of exactly nn distinct subsets. Furthermore, the sums of the elements in UU and U+kU + k differ by k∣U∣(mod n)k|U|(\text{mod } n), so exactly one element of each class has sum divisible by nn. It follows that
∣F′∣=2+2n−2n,∣F∣=12∣F′∣=2n−1+n−1n. |F'| = 2 + \frac{2^n - 2}{n}, \quad |F| = \frac{1}{2}|F'| = \frac{2^{n-1} + n - 1}{n}.
Therefore,
m=∣S1∣−∣S2∣+∣S3∣−⋯+∣Sn∣−∣F∣=(n−2)n−1−(n−2)n−2+2(n−2)n−3−22(n−2)n−4+⋯+2n−2−2n−1+n−1n=(n−2)n−1−(n−2)n−1−2n−1n−2n−1+n−1n=(n−1)(n−2)n−1−(n−1)n. \begin{align*} m &= |S_1| - |S_2| + |S_3| - \dots + |S_n| - |F| \\ &= (n-2)^{n-1} - (n-2)^{n-2} + 2(n-2)^{n-3} \\ &\quad - 2^2(n-2)^{n-4} + \dots + 2^{n-2} - \frac{2^{n-1} + n-1}{n} \\ &= (n-2)^{n-1} - \frac{(n-2)^{n-1} - 2^{n-1}}{n} - \frac{2^{n-1} + n-1}{n} \\ &= \frac{(n-1)(n-2)^{n-1} - (n-1)}{n}. \end{align*}
As before, multiplying by nn gives the desired answer.

Second Solution: The answer is (n−1)n−(n−1)(n-1)^n - (n-1) for part (a) and (n−1)((n−2)n−1−1)(n-1)((n-2)^{n-1} - 1) for part (b). Observe that the number of good sequences is clearly the same for any choice of a0a_0. Fixing a0a_0, we represent the choices for the differences ai−ai−1(modn)a_i - a_{i-1} \pmod n with the generating function
gi(x)=1+x+x2+⋯+xi−1+xi+1+⋯+xn−1=p(x)−xi, g_i(x) = 1 + x + x^2 + \dots + x^{i-1} + x^{i+1} + \dots + x^{n-1} = p(x) - x^i,
where p(x)=1+x+x2+⋯+xn−1p(x) = 1 + x + x^2 + \cdots + x^{n-1}. Then the generating function representing all the possibilities for a1−a0,a2−a1,…,an−1−an−2a_1 - a_0, a_2 - a_1, \ldots, a_{n-1} - a_{n-2} is
g(x)=∏i=1n−1gi(x)=∏i=1n−1(p(x)−xi). g(x) = \prod_{i=1}^{n-1} g_i(x) = \prod_{i=1}^{n-1} (p(x) - x^i).
The condition that a0−an−1≢0(modn)a_0 - a_{n-1} \not\equiv 0 \pmod{n} means that we wish to sum the coefficients of the xkx^k terms of g(x)g(x) for n∤kn \not\mid k.

Now the sum of all the coefficients is simply g(1)=(n−1)n−1g(1) = (n-1)^{n-1}. The sum of the coefficients of the xkx^k terms for n∣kn \mid k can be obtained by taking
1n∑j=0n−1g(ϵj), \frac{1}{n} \sum_{j=0}^{n-1} g(\epsilon^j),
where ϵ=e2πi/n\epsilon = e^{2\pi i/n} is a primitive nthn^{\text{th}} root of unity. As we noted above, g(1)=(n−1)n−1g(1) = (n-1)^{n-1}. For n>j>0n > j > 0, note that p(ϵj)=0p(\epsilon^j) = 0, so
g(ϵj)=∏k=1n−1−ϵkj=(−1)n−1ϵn(n−1)/2j=1, g(\epsilon^j) = \prod_{k=1}^{n-1} -\epsilon^{kj} = (-1)^{n-1} \epsilon^{n(n-1)/2} j = 1,
as nn is odd. Therefore, the sum of the coefficients of the terms with powers not dividing nn is
(n−1)n−1−1n((n−1)n−1+(n−1))=1n((n−1)n−(n−1)). (n-1)^{n-1} - \frac{1}{n}((n-1)^{n-1} + (n-1)) = \frac{1}{n}((n-1)^n - (n-1)).
Remembering that we had nn choices of a0a_0 to begin with, we obtain (n−1)n−(n−1)(n-1)^n - (n-1) as the answer to part (a).

For part (b), we change our generating functions to
hi(x)=p(x)−(xi+x2i),h(x)=∏i=1n−1hi(x). h_i(x) = p(x) - (x^i + x^{2i}), \quad h(x) = \prod_{i=1}^{n-1} h_i(x).
Note that for 1≤i≤n−11 \le i \le n-1, the terms xix^i and x2ix^{2i} both appear because i≠2i(modn)i \ne 2i \pmod n as nn is odd. For the final condition, however, n≡2n≡0(modn)n \equiv 2n \equiv 0 \pmod n, so we are still counting those terms—and only those terms—with powers not divisible by nn. Hence, using the same method as before, we have h(1)=(n−2)n−1h(1) = (n-2)^{n-1},
h(ϵj)=∏k=1n−1−ϵkj(1+ϵkj)=∏k=1n−1(1+ϵk), h(\epsilon^j) = \prod_{k=1}^{n-1} -\epsilon^{kj}(1 + \epsilon^{kj}) = \prod_{k=1}^{n-1} (1 + \epsilon^k),
for 1≤j≤n−11 \le j \le n-1, as nn is prime. Now, 1+ϵi1+\epsilon^i, i=0,1,…,n−1i=0,1,\dots,n-1, are all of the roots of the polynomial (x−1)n−1(x-1)^n-1. Therefore, their product is (−1)n=−1(-1)^n = -1 times the constant coefficient of the polynomial, −2-2. Hence, the product of the roots not including i=0i=0 (in which case 1+ϵ0=21+\epsilon^0 = 2) is 1. Therefore, h(ϵj)=1h(\epsilon^j) = 1.

It follows that the number of sequences for a fixed a0a_0 is
(n−2)n−1−1n((n−2)n−1+(n−1))=1n((n−1)((n−2)n−1−1)), (n-2)^{n-1} - \frac{1}{n}((n-2)^{n-1} + (n-1)) = \frac{1}{n}((n-1)((n-2)^{n-1} - 1)),
so the answer to part (b) is (n−1)((n−2)n−1−1)(n-1)((n-2)^{n-1} - 1).

Source: MathNet, licensed CC-BY-4.0. Statement reproduced verbatim; metadata (topic, difficulty, ordering) added by this project.