Problems > Remove a Power of Two > Editorial

Remove a Power of Two — Solution & Editorial

Back to the Problem

Compute Grundy values g[n] = mex of reachable positions' Grundy values up to the maximum query; g[n] ≠ 0 means the first player wins.

Complexity: O(max n · moves)