MathDB
CSMC 2018 Part B Problem 3

Source:

November 24, 2018
CSMCCSMC 2018

Problem Statement

A string of length nn is a sequence of nn characters from a specified set. For example, BCAABBCAAB is a string of length 5 with characters from the set {A,B,C}\{A,B,C\}. A substring of a given string is a string of characters that occur consecutively and in order in the given string. For example, the string CACA is a substring of BCAABBCAAB but BABA is not a substring of BCAABBCAAB. [*]List all strings of length 4 with characters from the set {A,B,C}\{A,B,C\} in which both the strings ABAB and BABA occur as substrings. (For example, the string ABACABAC should appear in your list.) [*]Determine the number of strings of length 7 with characters from the set {A,B,C}\{A,B,C\} in which CCCC occures as a substring. [*]Let f(n)f(n) be the number of strings of length nn with characters from the set {A,B,C}\{A,B,C\} such that [*]CCCC occurs as a substring, and[*]if either ABAB or BABA occurs as a substring then there is an occurrence of the substring CCCC to its left. (for example, when n  =  6n\;=\;6, the strings CCAABCCCAABC and ACCBBBACCBBB and CCABCCCCABCC satisfy the requirements, but the strings BACCABBACCAB and ACBBABACBBAB and ACBCACACBCAC do not). Prove that f(2097)f(2097) is a multiple of 9797.