Skip to main content
OlympiadHQ

Browse · MathNet

Print

Team selection tests for JBMO 2018

Saudi Arabia 2018 counting and probability

Problem

Let be a positive integer. Consider bags of candy, each of them has exactly 1 candy. Ali and Omar take turns playing the following game (Ali moves first): At each turn, the player takes two bags containing the numbers of candy as for some coprime integers and then merges them into one bag. Whoever cannot perform this action will be the loser. Who has the strategy to win this game?
Solution
We shall prove that for all , Omar always has the strategy to win.

First, Ali has to merge some two bags of 1 candy into one bag of 2 candies. We prove that Omar can turn the state of all bags into: one bag contains odd number of candies and the others just have one candy each.

Indeed, in the second turn, Omar merges the bag of 2 candies with some bag of 1 candy to get one bag of 3 candies. Suppose that after a turn of Omar, there is a bag of candies (with ) and the other bags just have one candy each. At the next turn of Ali, there are two cases:

- If Ali merges two bags of 1 candy to one bag of 2 candies, then on the next turn, Omar merges that bag with the bag of candies to get a bag of candies.

- If Ali merges the bag of candies with some bag of 1 candy to get another bag of , then on the next turn, Omar merges that bag with some bag of 1 candy to get a bag of candies.

Hence, Omar always can control the state of bags like that. Note that after two turns of players, the number of bags reduces by 2. Finally, if after a turn of Omar, there is only one bag of candies then Ali will be the loser. Otherwise, there is a bag of candies and 3 bags of 1 candy. There are two cases:

- If Ali merges two bags of 1 candy then Omar merges the bag of with the bag of 1 candy; then after that turn, there are a bag of 2 candies and a bag of which implies that Ali loses.

- If Ali merges the bag of candies with a bag of 1 candy then Omar merges two bags of 1 candy to make two bags of even number of candies as above.

Therefore, in all cases of , Omar always can win the game.
Final answer
Omar always has a winning strategy for all starting counts greater than two.

Techniques

Games / greedy algorithmsInvariants / monovariantsGreatest common divisors (gcd)