Olympiad Maths Prep

Track / Stage 9 / 44 of 80 #1924 of 2000

Problem 1924

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, aiai1≢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, aiai1≢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, read the official solution, then mark yourself honestly — the ladder only means something if the record is true.

Official solution

First Solution: The answer is (n1)n(n1)(n-1)^n - (n-1) for part (a) and (n1)((n2)n11)(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 aiai1≢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, (ni)(n-i) and fails to satisfy conditions (ni+2)(n-i+2), (ni+3)(n-i+3), \dots, (n)(n). Note that there is no constraint on whether or not AA satisfies condition (ni+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=S1S2+S3+SnF. 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)(n2)(n1)S2(1)(2)(3)(n2)(n)S3(1)(2)(3)(n1)(n)Sn(2)(3)(n2)(n1)(n)F(1)(2)(3)(n2)(n1)(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 Sn1,Sn2S_{n-1}, S_{n-2}. As one of Sn1,Sn2|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 i1i-1 conditions determines the terms an1,an2,,ani+1a_{n-1}, a_{n-2}, \dots, a_{n-i+1}, whereas there are just n1n-1 ways to satisfy each of the conditions (1), (2), \dots, (ni)(n-i), producing (n1)ni(n-1)^{n-i} subsequences a0,a1,,ania_0, a_1, \dots, a_{n-i}. As there is no constraint on ani+1ania_{n-i+1} - a_{n-i}, we have found all sequences in SiS_i. Hence, Si=(n1)ni|S_i| = (n-1)^{n-i}. As for FF, there is clearly exactly one way to fail every single condition, because 1+2++(n1)=n(n1)21+2+\dots+(n-1) = \frac{n(n-1)}{2} is divisible by nn. Therefore, SnF=0|S_n| - F = 0 and
m=S1S2+Sn1=(n1)n1(n1)n2+(n1)=(n1)n(n1)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 1in11 \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 anan1≢0(modn)a_n - a_{n-1} \not\equiv 0 \pmod{n}. Hence, we have
S1=(n2)n1andSi=2i2(n2)ni, |S_1| = (n-2)^{n-1} \quad \text{and} \quad |S_i| = 2^{i-2}(n-2)^{n-i},
for 2in2 \le i \le n. Finding F|F| is trickier in this case, however. Considering the differences bi=aiai1b_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++bn0(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), bn0(modn)b_n \equiv 0 \pmod{n} is forced; hence, we are actually looking at 2n12^{n-1} sums b1+b2++bn1b_1 + b_2 + \dots + b_{n-1} rather than 2n2^n. Now, as n[1+2++(n1)]=n(n1)2n \mid [1 + 2 + \dots + (n-1)] = \frac{n(n-1)}{2}, we can equivalently consider sums of terms ci=biic_i = b_i - i. That is, we wish to find the number of choices of c1,c2,,cn1c_1, c_2, \dots, c_{n-1} such that
c1+c2++cn10(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=1n1\{c_i\}_{i=1}^{n-1}. That is, letting
F={(c1,c2,,cn)[t]ci=0 or i,c1+c2++cn0(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=12F|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 FF' 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 UTU \subset T have from 1 to n1n-1 elements. Write U+kU+k for the set {x+kxU}\{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+(n1)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 kU(mod n)k|U|(\text{mod } n), so exactly one element of each class has sum divisible by nn. It follows that
F=2+2n2n,F=12F=2n1+n1n. |F'| = 2 + \frac{2^n - 2}{n}, \quad |F| = \frac{1}{2}|F'| = \frac{2^{n-1} + n - 1}{n}.
Therefore,
m=S1S2+S3+SnF=(n2)n1(n2)n2+2(n2)n322(n2)n4++2n22n1+n1n=(n2)n1(n2)n12n1n2n1+n1n=(n1)(n2)n1(n1)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 (n1)n(n1)(n-1)^n - (n-1) for part (a) and (n1)((n2)n11)(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 aiai1(modn)a_i - a_{i-1} \pmod n with the generating function
gi(x)=1+x+x2++xi1+xi+1++xn1=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++xn1p(x) = 1 + x + x^2 + \cdots + x^{n-1}. Then the generating function representing all the possibilities for a1a0,a2a1,,an1an2a_1 - a_0, a_2 - a_1, \ldots, a_{n-1} - a_{n-2} is
g(x)=i=1n1gi(x)=i=1n1(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 a0an1≢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)=(n1)n1g(1) = (n-1)^{n-1}. The sum of the coefficients of the xkx^k terms for nkn \mid k can be obtained by taking
1nj=0n1g(ϵ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)=(n1)n1g(1) = (n-1)^{n-1}. For n>j>0n > j > 0, note that p(ϵj)=0p(\epsilon^j) = 0, so
g(ϵj)=k=1n1ϵkj=(1)n1ϵn(n1)/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
(n1)n11n((n1)n1+(n1))=1n((n1)n(n1)). (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 (n1)n(n1)(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=1n1hi(x). h_i(x) = p(x) - (x^i + x^{2i}), \quad h(x) = \prod_{i=1}^{n-1} h_i(x).
Note that for 1in11 \le i \le n-1, the terms xix^i and x2ix^{2i} both appear because i2i(modn)i \ne 2i \pmod n as nn is odd. For the final condition, however, n2n0(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)=(n2)n1h(1) = (n-2)^{n-1},
h(ϵj)=k=1n1ϵkj(1+ϵkj)=k=1n1(1+ϵk), h(\epsilon^j) = \prod_{k=1}^{n-1} -\epsilon^{kj}(1 + \epsilon^{kj}) = \prod_{k=1}^{n-1} (1 + \epsilon^k),
for 1jn11 \le j \le n-1, as nn is prime. Now, 1+ϵi1+\epsilon^i, i=0,1,,n1i=0,1,\dots,n-1, are all of the roots of the polynomial (x1)n1(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
(n2)n11n((n2)n1+(n1))=1n((n1)((n2)n11)), (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 (n1)((n2)n11)(n-1)((n-2)^{n-1} - 1).

Source: MathNet, licensed CC-BY-4.0. Statement and solution reproduced as published; topic, difficulty and ordering added by this site.