33 lines
561 B
C++
33 lines
561 B
C++
#include <iostream>
|
|
#include <cmath>
|
|
#include <algorithm>
|
|
using namespace std;
|
|
|
|
bool areCoprimes(int a, int b, int c) {
|
|
return __gcd(a, b) == 1 && __gcd(a, c) == 1 && __gcd(b, c) == 1;
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
|
int c;
|
|
cin >> c;
|
|
|
|
uint64_t cSqr = pow(c, 2);
|
|
bool found = false;
|
|
for (int a = 1; a <= c; a++) {
|
|
uint64_t aSqr = pow(a, 2);
|
|
for (int b = a; b <= c; b++) {
|
|
if (aSqr + pow(b, 2) == cSqr && areCoprimes(a, b, c)) {
|
|
cout << a << " " << b << " " << c << endl;
|
|
found = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!found) {
|
|
cout << "NOPE" << endl;
|
|
}
|
|
|
|
return 0;
|
|
} |