← All problemsSign in

Stick Game

CSESMathematicsOpen on judge ↗

Consider a game where two players remove sticks from a heap. The players move alternately, and the player who removes the last stick wins the game. A set P=\{p_1,p_2,\ldots,p_k\} determines the allowed moves. For example, if P=\{1,3,4\}, a player may remove 1, 3 or 4 sticks. Your task is find out for each number of sticks 1,2,\dots,n if the first player has a winning or losing position. Input

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start