Browse · MathNet
PrintCzech-Polish-Slovak Mathematical Match
counting and probability
Problem
Let be a fixed positive integer. A finite sequence of integers is written on a blackboard. Pepa and Geoff are playing a game that proceeds in rounds as follows. In each round, Pepa first partitions the sequence that is currently on the blackboard into two or more contiguous subsequences (that is, consisting of numbers appearing consecutively). However, if the number of these subsequences is larger than 2, then the sum of numbers in each of them has to be divisible by . Then Geoff selects one of the subsequences that Pepa has formed and wipes all the other subsequences from the blackboard. The game finishes once there is only one number left on the board. Prove that Pepa may choose his moves so that independently of the moves of Geoff, the game finishes after at most rounds.
(Poland)
(Poland)
Solution
A finite sequence of integers is called a word and any its contiguous subsequence is called a subword. For a word , by we denote the sum of numbers in . A prefix of a word is a subword starting at the beginning of the word, and a prefix is proper if it is neither empty nor the whole word. Analogously we define suffixes. For a word , let be the set of remainders modulo for which there exists a proper prefix of with . In other words, comprises different remainders modulo realized by sums of numbers in proper prefixes of . Define the rank of as . We shall prove the following statement: given a word on the board, Pepa can always play at most 3 rounds so that the rank of the remaining word is strictly smaller than the rank of . Since the rank of the initial word is at most and the rank of a word is 0 if and only if it consists of one number, in this way Pepa may force the end of the game within at most rounds. Assume then that the word on the board has length larger than 1, and take any . Suppose that the proper prefixes of giving remainder modulo end at positions , where . Consider the following partition of into subwords: where is the prefix up to position , each for is the subword between positions and , and is the suffix from position till the end of the word. We observe that the rank of each of subword is strictly smaller than the rank of . For this is trivial: since is the first position at which a prefix of has sum congruent to modulo , we have that . For , take any proper prefix of , let , and let be the remainder of modulo . Observe that . Therefore, the remainders realized by proper prefixes of are exactly the remainders realized by prefixes as above with subtracted modulo . Since between and there is no position at which a prefix of has sum congruent to modulo , we infer that none of prefixes as above has sum congruent to modulo . This implies that , so . Note that for each by construction. All these observations lead to the following three-turn strategy for Pepa: Partition into and . If Geoff chooses , then the rank of the word has already decreased. Otherwise Geoff chooses . Partition into and . If Geoff chooses , then the rank of the word has already decreased. Otherwise Geoff chooses . * Partition into , which are all words with sums of numbers divisible by . Regardless of the move of Geoff, the rank of the word chosen by him is strictly smaller than the rank of . This concludes the proof.
Techniques
Invariants / monovariantsGames / greedy algorithms