Remove a Perfect Power
A single pile of n stones; a move removes a perfect power (4, 8, 9, 16, 25, 27, ... — ab with b ≥ 2) or 1. The player unable to move loses. For each query n, print the winner.
Input: the first line has Q; each of the next Q lines has a pile size n.
Output: one line per query.
Constraints:
- 1 ≤ Q ≤ 104
- 0 ≤ n ≤ 104
Sample Tests
Input 1
3 0 4 9
Output 1
SECOND FIRST FIRST
Discussion (opens after you solve — no spoilers before)
No comments yet.