Skip to main content
OlympiadHQ

Browse · MathNet

Print

Final Round, September 2019

Netherlands 2019 counting and probability

Problem

Thomas and Nils are playing a game. They have a number of cards, numbered , , , et cetera. At the start, all cards are lying face up on the table. They take alternate turns. The person whose turn it is, chooses a card that is still lying on the table and decides to either keep the card himself or to give it to the other player. When all cards are gone, each of them calculates the sum of the numbers on his own cards. If the difference between these two outcomes is divisible by , then Thomas wins. If not, then Nils wins.

a. Suppose they are playing with cards (numbered from to ) and that Thomas starts. Prove that Nils can play in such a way that he will win the game with certainty.

b. Suppose they are playing with cards (numbered from to ) and that Nils starts. Which of the two players can play in such a way that he wins with certainty?
Solution
a. Thomas and Nils both make moves and Nils makes the last move. Nils can make sure that the last card on the table contains a number that is not divisible by . Indeed, he could start taking cards with numbers that are divisible by , until all these cards are gone. Because there are only such cards, he has enough turns to achieve that.

We now consider the situation before the last move of Nils. Let be the number on the last card, and let the sums of the numbers of Thomas and Nils at that very moment be and . Nils has two options. If he gives away the last card, the difference between the outcomes becomes , and if he keeps the card, the difference becomes . Nils is able to win, unless both numbers are divisible by . But in that case would also be divisible by . Because is not divisible by , the number is also not divisible by and hence Nils can win with certainty.

b. Nils can win. We distinguish three types of cards, depending on the number on the card: type (the number has remainder when dividing by ), type (the number has remainder when dividing by ), and type (the number is divisible by ). Because and the card is of type , there are cards of type , cards of type , and cards of type .

In order to win, Nils chooses a card of type in his first turn (and gives it to Thomas). Then there are cards of type left, of type , and of type . In the next turns he responds to Thomas's move in the following way (as long as he is able to).

(i) If Thomas chooses a card of type , then Nils chooses a card of type and gives it to the same person that got Thomas's card.

(ii) If Thomas chooses a card of type , then Nils chooses a card of type and gives it to the same person that got Thomas's card.

(iii) If Thomas chooses a card of type , then Nils does the same (and gives the card to Thomas).

As long as Nils keeps this up, the sum of each player's cards is divisible by after his turn (because a number of type and a number of type add up to a number which is divisible by ).

Because the number of cards of type is always even after Nils's turn, Nils can always execute his planned move in case (iii). Because the number of cards of type is always greater than that of type after Nils's turn, he can also always execute his planned move in case (ii). Only at the moment when all cards of type are gone and Thomas takes the last card of type (case (i)), Nils cannot execute his planned move. However, in that case Nils cannot lose anymore. Indeed, after Thomas's turn the sum of the cards of one player is still divisible by , but the sum of the cards of the other player is not divisible by anymore. Because there are only cards of type left now, this will stay the same until all cards are gone. At the end, the difference between the sums of both players is not divisible by and Nils wins.
Final answer
a: Nils wins with certainty. b: Nils wins with certainty.

Techniques

Invariants / monovariantsGames / greedy algorithmsModular Arithmetic