Skip to main content
OlympiadHQ

Browse · MathNet

Print

58th Ukrainian National Mathematical Olympiad

Ukraine counting and probability

Problem

The teacher wrote digits on the board until a -digit number was formed. After that Andriy and Olesya played a game as follows. Alternately (after Andriy begins) they cross out digits as follows: either the first two digits of the number remaining after the previous move, or the last two digits, or the first and last digits of that number. The game ends when the two-digit number is left. Olesya wins, if this number is a multiple of , otherwise Andriy wins. Who will win if both players play according to the best strategy?

(Bogdan Rublyov)
Solution
Since we are only interested in divisibility by , we can change all the digits as follows: , and , which will give us the equivalent problem. Then, after moves, a -digit number will be left on the board, and Olesya will be making the last move. Obviously, these digits left will be the ones that were initially together (following one another) on the board. Therefore, the possible options are: , or . In either of these cases there is a pair of digits that comprises number , and this is exactly the pair which Olesya should leave on the board for her to win.
Final answer
Olesya

Techniques

Games / greedy algorithmsInvariants / monovariantsDivisibility / Factorization