#include <iostream>
#include <math.h>
using namespace std;
bool l_p(double a, double b, double h, int n){
double p=sqrt(float(pow(a,2)+pow(b,2)+pow(h,2)));
if(p!=int(p)){
return false;
}
else if(p<=n){
return true;
}
return false;
}
int main(){
int n,l=0;
cin>>n;
for(int a=1;a<=n;a++){
for(int b=a;b<=n;b++){
for(int h=1;h<=n;h++){
if(l_p(a,b,h,n)){
l++;
}
}
}
}
cout<<l;
}
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 | #include <iostream> #include <math.h> using namespace std; bool l_p(double a, double b, double h, int n){ double p=sqrt(float(pow(a,2)+pow(b,2)+pow(h,2))); if(p!=int(p)){ return false; } else if(p<=n){ return true; } return false; } int main(){ int n,l=0; cin>>n; for(int a=1;a<=n;a++){ for(int b=a;b<=n;b++){ for(int h=1;h<=n;h++){ if(l_p(a,b,h,n)){ l++; } } } } cout<<l; } |
English