Data Structures & AlgorithmsHardICPC regional · Codeforces Div2 D

Problem: Subtraction game: from n stones a player may remove 1, 3 or 4 stones; the player who cannot move loses (no stones left on their turn is a loss). Starting with 10 stones, the first player wins with optimal play. Answer 1 if the first player wins, 0 otherwise.

  1. A. 1
  2. B. 2
  3. C. 0
  4. D. 3

Correct answer: A. 1

Positions are winning if some move reaches a losing position. The recursion over remaining stones settles the game; a naive parity argument does not apply because the move set is not {1}.

More Coding Interview Problems questions

Exams that ask this topic