Cycle-13. A positive integer solution for a special equation (15) time limit MS Memory limit 65536 KB code length limit 8000 B procedure StandardAuthor Zhang Tong Hongyu (Zhejiang University)
The subject requires that all positive integer solutions of the equation x2+y2=n be obtained for any given positive integer n.
Input format:
The input gives a positive integer n (<=10000) in a row.
Output format:
The output equation x2+y2=n all positive integer solutions, of which x<=y. Each group of solutions accounted for 1 rows, and the two numbers were separated by 1 spaces and output in ascending order of X. If there is no solution, the output is "no solution".
Input Sample 1:
884
Output Example 1:
10 2820 22
Input Sample 2:
11
Output Example 2:
No Solution
1#include <stdio.h>2#include <stdlib.h>3#include <math.h>4 intMain ()5 {6 intN;7scanf"%d", &n);8 intx, y, flag =0;9 Doublem =sqrt (n);Ten for(x =1; X <= m +1; X + +) One { A for(y = x; y <= m +1; y++) - { - if(x*x + Y*y = =N) the { -printf"%d%d\n", x, y); -Flag =1; - } + } - } + if(!flag) Aprintf"No solution\n"); at return 0; -}
Cycle-13. Finding positive integer solutions to special equations