Subtraction Game {1,2,3}
Several piles; a move removes from one pile a number of stones in {1, 2, 3}. A player who cannot move loses. With both playing optimally and the first player moving first, who wins?
Input: the first line has the number of piles K; the second line has the pile sizes.
Output: First or Second.
Constraints:
- 1 ≤ K ≤ 105
- 0 ≤ pile size ≤ 104
Sample Tests
Input 1
2 3 3
Output 1
Second
Input 2
1 0
Output 2
Second
Input 3
3 1 2 4
Output 3
First
Discussion (opens after you solve — no spoilers before)
No comments yet.