Unofficial archive — problems, solutions & results © IMC, reproduced with permission.

IMC / 2022 / Problems / Day 1, P3

IMC 2022 · Day 1 · P3

very hard

Let pp be a prime number. A flea is staying at point 0 of the real line. At each minute, the flea has three possibilities: to stay at its position, or to move by 1 to the left or to the right. After p1p - 1 minutes, it wants to be at 0 again. Denote by f(p)f(p) the number of its strategies to do this (for example, f(3)=3f(3) = 3: it may either stay at 0 for the entire time, or go to the left and then to the right, or go to the right and then to the left). Find f(p)f(p) modulo pp.

(proposed by Fedor Petrov, St. Petersburg)

Solution 1 of 2 (official)

Hint: Find a recurrence for f(p)f(p) or use generating functions.

The answer is f(p)0mod3f(p) \equiv 0 \mod 3

for p=3p = 3, f(p)1mod3f(p) \equiv 1 \mod 3 for p=3k+1p = 3k + 1, and f(p)1mod3f(p) \equiv -1 \mod 3 for p=3k1p = 3k - 1.

The case p=3p = 3 is already considered, let further p3p \ne 3. For a residue ii modulo pp denote by ai(k)a_i(k) the number of Flea strategies for which she is at position ii modulo pp after kk minutes. Then f(p)=a0(p1)f(p) = a_0(p-1). The natural recurrence is ai(k+1)=ai1(k)+ai(k)+ai+1(k)a_i(k+1) = a_{i-1}(k) + a_i(k) + a_{i+1}(k), where the indices are taken modulo pp. The idea is that modulo pp we have a0(p)3a_0(p) \equiv 3 and ai(p)0a_i(p) \equiv 0. Indeed, for all strategies for pp minutes for which not all pp actions are the same, we may cyclically shift the actions, and so we partition such strategies onto groups by pp strategies which result with the same ii. Remaining three strategies correspond to i=0i = 0. Thus, if we denote xi=ai(p1)x_i = a_i(p-1), we get a system of equations x1+x0+x1=3x_{-1} + x_0 + x_1 = 3, xi1+xi+xi+1=0x_{i-1} + x_i + x_{i+1} = 0 for all i=1,,p1i = 1, \dots, p-1. It is not hard to solve this system (using the 3-periodicity, for example). For p=3k+1p = 3k + 1 we get (x0,x1,,xp1)=(1,1,2,1,1,2,,1)(x_0, x_1, \dots, x_{p-1}) = (1, 1, -2, 1, 1, -2, \dots, 1), and (x0,x1,,xp1)=(1,2,1,1,2,,2)(x_0, x_1, \dots, x_{p-1}) = (-1, 2, -1, -1, 2, \dots, 2) for p=3k+2p = 3k + 2.

Solution 2 of 2 (official)

Note that f(p)f(p) is the constant term of the Laurent polynomial (x+1+1/x)p1(x + 1 + 1/x)^{p-1} (the moves to right, to left and staying are in natural correspondence with xx, 1/x1/x and 1.) Thus, working with power series over Fp\mathbb{F}_p we get (using the notation [xk]P(x)[x^k] P(x) for the coefficient of xkx^k in PP) f(p)=[xp1](1+x+x2)p1=[xp1](1x3)p1(1x)1p=[xp1](1x3)p(1x)p(1x3)1(1x)=[xp1](1x3p)(1xp)1(1x3)1(1x)=[xp1](1x3)1(1x),\begin{align*} f(p) &= [x^{p-1}] (1 + x + x^2)^{p-1} = [x^{p-1}] (1 - x^3)^{p-1} (1 - x)^{1-p} = [x^{p-1}] (1 - x^3)^p (1 - x)^{-p} (1 - x^3)^{-1} (1 - x) \\ &= [x^{p-1}] (1 - x^{3p})(1 - x^p)^{-1} (1 - x^3)^{-1} (1 - x) = [x^{p-1}] (1 - x^3)^{-1} (1 - x), \end{align*} and expanding (1x3)1=x3k(1 - x^3)^{-1} = \sum x^{3k} we get the answer.

How the field did

contestants scored
589
average (of 10)
2.32
solved (≥ 80%)
12.2%
near-0 (≤ 10%)
54.8%
discrimination
0.64

Score distribution (field cohort)

Computed on contestants with a meaningful total (field cohort); discrimination is the corrected item–total correlation.

Similar problems

IMC 2016 · Day 2 · P8very hardavg 2.1/10 · solved 10% · near-0 62% · disc 0.38
IMC 2025 · Day 1 · P5killeravg 1.0/10 · solved 5% · near-0 79% · disc 0.49
IMC 2022 · Day 2 · P6hardavg 3.1/10 · solved 21% · near-0 55% · disc 0.53
IMC 1999 · Day 2 · P12killeravg 0.4/10 · solved 2% · near-0 91% · disc 0.30