Skip to main content

2015 AMC 12A Problem 22

Problem 22 of 25HarderNumber TheoryCounting & Probability

For each positive integer n,n, let S(n)S(n) be the number of sequences of length nn consisting solely of the letters AA and B,B, with no more than three AAs in a row and no more than three BBs in a row. What is the remainder when S(2015)S(2015) is divided by 12?12?

Answer choices

Show solution

Solution

Note S(1)=2,S(1) = 2, S(2)=4,S(2) = 4, S(3)=8.S(3) = 8. Every valid sequence ends in a run of one, two, or three equal letters; removing that run leaves a valid sequence of length n1,n-1, n2,n-2, or n3.n-3. Thus S(n)=S(n1)+S(n2)+S(n3). \begin{aligned} &S(n) = S(n-1) + S(n-2) \\ &\quad {}+ S(n-3). \end{aligned} Modulo 3,3, the first 1313 terms are 2,1,2,2,2,0,1,0,1,2,0,0,2.2,1,2,2,2,0,1,0,1,2,0,0,2. The next three terms are 2,1,2,2,1,2, which reproduce the initial state, so the recurrence repeats with period 13.13. Since 2015=13155,2015 = 13\cdot 155, it follows that S(2015)S(13)2(mod3).S(2015) \equiv S(13) \equiv 2 \pmod 3. Modulo 4,4, the terms repeat as 2,0,0,2,2,0,0,2, because the next three-term state after these four terms is again (2,0,0).(2,0,0). Thus the period is 4.4. As 2015=4503+3,2015 = 4\cdot 503 + 3, we have S(2015)S(3)0(mod4).S(2015) \equiv S(3) \equiv 0 \pmod 4. Writing S(2015)=4k,S(2015) = 4k, the condition 4k2(mod3)4k \equiv 2 \pmod 3 gives k2(mod3),k \equiv 2 \pmod 3, so S(2015)8(mod12).S(2015) \equiv 8 \pmod{12}. Thus, the correct answer is D.

More practice

Concepts: recursive counting · modular arithmetic · Chinese Remainder Theorem

Problem text and solution from the LIVE past-contest archive. See also the AoPS wiki page for community solutions.