~/algor $ cat problems/for-pifagor-uchliklari
Pythagorean triples
Medium
1000 ms
64 MB
49%
A positive integer $N$ is given. Find all Pythagorean triples of positive integers $(a, b, c)$ satisfying:
$$a^{2} + b^{2} = c^{2}, \qquad a \lt b \lt c \le N$$
Input
One positive integer $N$.
Output
Each triple on a separate line: $a$, $b$, $c$ separated by spaces. The triples are ordered by increasing $a$, and for equal $a$ by increasing $b$. The last line contains the number of triples (if there are none, just 0).
Note
$1 \le N \le 100$
Examples
Input #1
13
Output #1
3 4 5 5 12 13 6 8 10 3
Input #2
4
Output #2
0