Misere Nim
Misere Nim: same moves as Nim, but the player who takes the last stone LOSES. Who wins with optimal play?
Input: the first line has the pile count K; the second line has the pile sizes.
Output: First or Second.
Constraints:
- 1 ≤ K ≤ 105
- 0 ≤ pile ≤ 109
Sample Tests
Input 1
2 1 1
Output 1
First
Input 2
3 1 2 3
Output 2
Second
Input 3
2 1 1
Output 3
First
Input 4
1 1
Output 4
Second
Discussion (opens after you solve — no spoilers before)
No comments yet.