WUSTOJ 1338: The minimum square sum(Java)
2024-08-26 19:04:55
题目链接:1338: The minimum square sum
Description
Given a prime p(p<108), you are to find min{x2+y2}, where x and y belongs to positive integer, so that x2+y2=0 (mod p).
输入一个质数 p,你找出两个正整数 x 和 y 使得 (x2+y2) mod p = 0,且 x2+y2 最小。
Input
Every line is a p. No more than 10001 test cases.
Output
The minimum square sum as described above.
Sample Input
2
3
5
7
11
13
Sample Output
2
18
5
98
242
13