If P = 2 or P = 4 * k + 1, P can be expressed in the form of the sum of two degrees (Euler and ferma have proved and have an exact method). Therefore, the answer is P.
If P = 4 * k + 3, set a ^ 2 = N (mod p) (n! = 0) it can be proved that there is no B, B ^ 2 = p-n (mod p). That is, if n is the square residue of p, p-n is not the square residue of P.
Proof: because a ^ 2 = N (mod P), N ^ (p-1)/2) = 1 (mod P) is obtained by Euler's criterion)
If B ^ 2 =-N (mod p) Then (-N) ^ (P-1/2) = 1 (mod P)
Put the symbol (-1) ^ (P-1/2) * n ^ (p-1)/2) on the left)
Because p is 4 * k + 3 type, the value of P (P-1)/2 is an odd number, so the left side cannot be equal to 1.
So a ^ 2 = 0 (mod p) B ^ 2 = 0 (mod p) so the answer is 2 * p * P
# Include <bits/stdc ++. h> using namespace STD; int main () {long P; while (scanf ("% LLD", & P) = 1) {If (P = 2 | P % 4 = 1) printf ("% LLD \ n", P); else printf ("% LLD \ n ", p * 2);} return 0 ;}