Approach hintTry it first, then revealHide
Compute Grundy values of small piles by brute force and look for a pattern tied to primes: even piles, odd primes and odd composites behave differently. A smallest-prime-factor sieve then yields every value to XOR.
More in Game Theory
| # | Problem | Platform | Difficulty | Open | 1st1st Visit | 2nd2nd Visit | RevRevise |
|---|---|---|---|---|---|---|---|
| 1 | Stone Game III | LeetCode | Hard | Solve Stone Game III on LeetCode (opens in a new tab) | |||
| 2 | 1-2-K Game | Codeforces | Medium 1700 | Solve 1-2-K Game on Codeforces (opens in a new tab) | |||
| 3 | Stoned Game | Codeforces | Hard 1800 | Solve Stoned Game on Codeforces (opens in a new tab) | |||
| 4 | A Lot of Games | Codeforces | Hard 1900 | Solve A Lot of Games on Codeforces (opens in a new tab) | |||
| 5 | GameGame | Codeforces | Hard 1900 | Solve GameGame on Codeforces (opens in a new tab) | |||
| 6 | Tree Tag | Codeforces | Hard 1900 | Solve Tree Tag on Codeforces (opens in a new tab) | |||
| 7 | Cat and Mouse | LeetCode | Hard | Solve Cat and Mouse on LeetCode (opens in a new tab) | |||
| 8 | Not a Nim Problem | Codeforces | Hard 2100 | Solve Not a Nim Problem on Codeforces (opens in a new tab) | |||
| 9 | Lieges of Legendre | Codeforces | Hard 2200 | Solve Lieges of Legendre on Codeforces (opens in a new tab) |