#P1857. 质数取石子
质数取石子
Description
There is a pile of stones on the table. In each move, a player may take a prime number of stones. The player who cannot make a move loses. What is the minimum number of moves needed to win? (One move means one player's turn.) Assume both players play optimally: the player who can force a win will win as quickly as possible, and the losing player will delay as long as possible.
Input Format
The first line contains , the number of test cases.
Each of the next lines contains the number of stones.
Output Format
For each test case, output one number. If the position is winning, output the minimum number of moves needed to win; otherwise, output .
3
8
9
16
1
-1
3
Hint
Constraints: the number of stones is , and .
Translated by ChatGPT 5
京公网安备 11011102002149号