luogu#P4296. [AHOI2007] 密码箱

[AHOI2007] 密码箱

Problem Description

By chance, Little Keke obtained a password box said to contain an ancient treasure map. The box can be opened by cracking the password, and the ancient symbols engraved on the back of the box serve as hints.

After painstaking deciphering, Little Keke discovered that these symbols describe a number and its relation to the password. Suppose this number is nn, and the password is xx. Then we have: the password xx is greater than or equal to 00 and less than nn, and the remainder of x2x^2 divided by nn is 11. Little Keke knows there may be more than one xx that satisfies these conditions, so she must compute all such xx; the correct password is among them. The computation is arduous—can you write a program to help?

Input Format

One line containing an integer nn (1n2×1091 \leq n \leq 2 \times 10^9).

Output Format

Find all xx that satisfy the conditions described above. If no such xx exists, output a single line None. Otherwise, output these xx in increasing order, one per line.

12
1
5
7
11

Hint

Translated by ChatGPT 5