Staircase Nim
Coins sit on stairs 1..N (ai coins on stair i). A move slides any positive number of coins from stair i down to stair i−1; coins reaching the ground (below stair 1) are gone. The player unable to move loses. Determine the winner.
Input: the first line has N; the second line has the N coin counts.
Output: FIRST or SECOND.
Constraints:
- 1 ≤ N ≤ 105
- 0 ≤ ai ≤ 109
Sample Tests
Input 1
3 1 2 3
Output 1
FIRST
Input 2
2 0 5
Output 2
SECOND
Discussion (opens after you solve — no spoilers before)
No comments yet.