Skip to main content
OlympiadHQ

Browse · MathNet

Print

Balkan Mathematical Olympiad

North Macedonia counting and probability

Problem

Alice and Bob play the following game: They start with two non-empty piles of coins. Taking turns, with Alice playing first, each player chooses a pile with an even number of coins and moves half of this pile to the other pile. The game ends if a player cannot move, in which case the other player wins. Determine all pairs of positive integers such that if initially the two piles have and coins respectively, then Bob has a winning strategy.
Solution
By we denote the largest nonnegative integer such that . A position (i.e. two piles of sizes and ) is said to be -happy if for some integer , and -unhappy if . We shall prove that Bob has a winning strategy if and only if the initial position is -happy for some even .

Given a -happy position, the player in turn is unable to play loses.

Given a -happy position with , the player in turn will transform it into one of positions and , both of which are -happy because Therefore, if the starting position is -happy, after moves they will get stuck at a -happy position, so Bob will win if and only if is even.

* Given a -unhappy position with odd and , Alice not play to position , because the new position is -happy and will lead to Bob's victory. Thus she must play to position . We claim that this position is also -unhappy. Indeed, if , then , whereas if , then .

Therefore a -unhappy position is winning for Alice if is odd, and drawing if is even.
Final answer
Bob has a winning strategy exactly when both piles have the same highest power of two dividing their sizes and this common exponent is even.

Techniques

Invariants / monovariantsGames / greedy algorithmsFactorization techniques