#include <bits/stdc++.h>
using namespace std;
int main(){
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
int n;
cin >> n;
int nn = n*n;
int odp = 0;
int ile = 0;
for (int i = 1;i < n;i++){
int ii = i*i;
for (int j = i;j < n;j++){
int jj = j*j;
for (int h = 1;h < n;h++){
int hh = h*h;
if (ii + jj + hh > nn){
break;
}
odp = sqrt(ii + jj + hh);
if (odp*odp == ii + jj + hh){
//cout << i << " " << j << " " << h << endl;
ile ++;
}
}
}
}
cout << ile << '\n';
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 <bits/stdc++.h> using namespace std; int main(){ std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); int n; cin >> n; int nn = n*n; int odp = 0; int ile = 0; for (int i = 1;i < n;i++){ int ii = i*i; for (int j = i;j < n;j++){ int jj = j*j; for (int h = 1;h < n;h++){ int hh = h*h; if (ii + jj + hh > nn){ break; } odp = sqrt(ii + jj + hh); if (odp*odp == ii + jj + hh){ //cout << i << " " << j << " " << h << endl; ile ++; } } } } cout << ile << '\n'; return 0; } |
English