Problems > Bounded Nim > Editorial

Bounded Nim — Solution & Editorial

Back to the Problem

Each pile is a subtraction game with Grundy value (pile mod (K+1)). XOR the Grundy values: non-zero means the first player wins (Sprague–Grundy).

Complexity: O(N)