#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
vector<int> preproc((n*n)+1);
for(int a=1;a<=n;a++){
for(int b=a;b<=n;b++){
if(a*a+b*b < preproc.size()){
preproc[a*a+b*b]++;
}
}
}
int wyn=0;
for(int sizee=1;sizee<=n;sizee++){
for(int h=1;h<=n;h++){
if(sizee*sizee - h*h > 0 && sizee*sizee - h*h < preproc.size())
wyn+=preproc[sizee*sizee - h*h];
}
}
cout << wyn << "\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 | #include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<int> preproc((n*n)+1); for(int a=1;a<=n;a++){ for(int b=a;b<=n;b++){ if(a*a+b*b < preproc.size()){ preproc[a*a+b*b]++; } } } int wyn=0; for(int sizee=1;sizee<=n;sizee++){ for(int h=1;h<=n;h++){ if(sizee*sizee - h*h > 0 && sizee*sizee - h*h < preproc.size()) wyn+=preproc[sizee*sizee - h*h]; } } cout << wyn << "\n"; return 0; } |
English