Subtract the square
Very easy
Execution time limit is 2 seconds
Runtime memory usage limit is 128 megabytes
Two players are engaged in the game "Take Away a Square". They start with a single pile containing n candies. During a player's turn, they can remove any number of candies k = t^2
(where t is a natural number) from the pile. The player who removes the last candy wins the game.
Your task is to identify all the losing positions in this game, given that the number of candies n does not exceed maxn.
Input
The input consists of a single line containing the integer maxn (1 ≤ maxn ≤ 10^6
).
Output
First, output the total number of losing positions. Then, list all these losing positions in ascending order, each on a new line.
Examples
Input #1
Answer #1
Submissions 135
Acceptance rate 41%