Problems > Remove a Perfect Power > Editorial

Remove a Perfect Power — Solution & Editorial

Back to the Problem

Grundy DP: g[n] = mex of reachable values; non-zero = first player wins.

Complexity: O(max n · moves)