Maths Olympiad Prep

Track / Stage 6 / 308 of 400 #1788 of 2444

Problem 1788

National Olympiad, first round
Combinatorics Difficulty 6.7 Prove it Taiwan IMO Selection Camp · Taiwan

Consider the permutation of 1,2,,n1, 2, \dots, n, which we denote as {a1,a2,,an}\{a_1, a_2, \dots, a_n\}.
Let f(n)f(n) be the number of these permutations satisfying the following conditions:
(1) a1=1a_1 = 1;
(2) aiai12,i=1,2,,n1|a_i - a_{i-1}| \le 2, i = 1, 2, \dots, n-1.
What is the residue when we divide f(2015)f(2015) by 4?

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

Solution: We discuss below the recurrence for f(n)f(n). Suppose a1,a2,,ana_1, a_2, \dots, a_n satisfies the conditions of the problem; since a1=1a_1 = 1, we have a2=2a_2 = 2 or 33.
(Case 1): a2=2a_2 = 2. Let bi=ai+11b_i = a_{i+1} - 1, then b1,b2,,bn1b_1, b_2, \dots, b_{n-1} satisfies the conditions of the problem, so the number of permutations in this case is f(n1)f(n-1).
(Case 2): a2=3a_2 = 3 and a3=2a_3 = 2, then we must have a4=4a_4 = 4. Consider ci=ai+33c_i = a_{i+3} - 3, then c1,c2,,cn3c_1, c_2, \dots, c_{n-3} satisfies the conditions of the problem, so the number of permutations in this case is f(n3)f(n-3).
(Case 3): a2=3a_2 = 3 and a34a_3 \ge 4. Suppose ak+1a_{k+1} is the first even number to appear in this permutation. By condition 2, a1,a2,,aka_1, a_2, \dots, a_k are 1,3,5,,2k11, 3, 5, \dots, 2k-1, and ak+1=2ka_{k+1} = 2k or 2k22k-2.
(Case 3-1): ak+1=2ka_{k+1} = 2k. By discussion, the only possibility is ak+2,ak+3,,an=2k2,2k4,,2a_{k+2}, a_{k+3}, \dots, a_n = 2k - 2, 2k-4, \dots, 2.

(Case 3-2): ak+1=2k2a_{k+1} = 2k - 2. By discussion, the only possibility is ak+2,ak+3,,an=2k4,2k6,,2a_{k+2}, a_{k+3}, \cdots, a_n = 2k - 4, 2k - 6, \cdots, 2.
Therefore, Case 3 has only one possibility: first arrange in increasing order all positive odd numbers n\le n, then arrange in decreasing order all positive even numbers n\le n.

Combining the above, we have
f(n)=f(n1)+f(n3)+1. f(n) = f(n-1) + f(n-3) + 1.
Using this formula to compute, we find that the residues of f(n)f(n) modulo 4, in order, are:
1, 1, 2, 0, 2, 1, 2, 1, 3, 2, 0, 0, 3, 0, 1, 1, 2, 0, 2, ...
which is a sequence with period 14. Also, 2015 = 143 ×\times 14 + 13, so
f(2015)=f(13)=3(mod4). f(2015) = f(13) = 3 \pmod{4}.

Source: MathNet, licensed CC-BY-4.0. Statement translated into English from zh; metadata (topic, difficulty, ordering) added by this project.