#include <iostream>
#include <cmath>
using namespace std;
int main() {
ios::sync_with_stdio(0);
int n;
cin >> n;
int counter = 0;
for (int nn = 1; nn <= n; nn++) {
for (int a = 1; a <= n; a++) {
for (int b = a; b <=n; b++) {
int c2 = nn*nn - a*a - b*b;
if (c2 > 0) {
int c = static_cast<int>(sqrt(c2));
if (c*c == c2 && /*c >= b &&*/ c <= n) {
//cout << a<< " " << b << " " << c << " " << c2 << endl;
counter++;
}
}
}
}
}
cout << counter;
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #include <iostream> #include <cmath> using namespace std; int main() { ios::sync_with_stdio(0); int n; cin >> n; int counter = 0; for (int nn = 1; nn <= n; nn++) { for (int a = 1; a <= n; a++) { for (int b = a; b <=n; b++) { int c2 = nn*nn - a*a - b*b; if (c2 > 0) { int c = static_cast<int>(sqrt(c2)); if (c*c == c2 && /*c >= b &&*/ c <= n) { //cout << a<< " " << b << " " << c << " " << c2 << endl; counter++; } } } } } cout << counter; return 0; } |
English