#59Medium
Pythagorean triples
Time: 1 s · Memory: 256 MB
- Nested loops
Statement
You are given a natural number . Find all triples of natural numbers with . For example, : .
Input format
A single integer ().
Output format
Each triple on its own line: , , . Order them by increasing , and for equal by increasing .
Examples
Input
13
Output
3 4 5 5 12 13 6 8 10
Input
5
Output
3 4 5
Note
Two nested loops are enough: choose and , compute and check that is an integer and . Three loops also work, but they are noticeably slower for .
