← All problemsSign in

Strange Nim Game

CodeChefRating 2445Open on judge ↗

Alice and Bob are playing a strange variant of the Nim game. The rules are as follows: 1. There are $N$ towers, with the $i$-th tower having $A_i$ rings. 2. On their turn, a player selects a tower $i$ that contains a positive number of rings, and a **positive** digit $d$ such that $d$ appears in the decimal representation of $A_i$. Then, they remove $d$ rings from the $i$-th tower. - For exa

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