#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;
int main() {
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
double n, p;
int count = 0;
cin >> n;
for (int a = 1; a <= n; a++) {
for (int b = a; b <= n; b++) {
for (int h = 1; h <= n; h++) {
p = sqrt(double(a * a + b * b + h * h));
if (p - int(p) == 0 && p <= n)count++;
}
}
}
cout << count;
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 | #include <iostream> #include <stdio.h> #include <cmath> using namespace std; int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); double n, p; int count = 0; cin >> n; for (int a = 1; a <= n; a++) { for (int b = a; b <= n; b++) { for (int h = 1; h <= n; h++) { p = sqrt(double(a * a + b * b + h * h)); if (p - int(p) == 0 && p <= n)count++; } } } cout << count; return 0; } |
English