#include <iostream> using namespace std; int possible[50000090]; int main() { int n, ans = 0; cin >> n; for(int b = 1; b <= n; b++) for(int a = 1; a <= b; a++) possible[b * b + a * a]++; for(int d = 1; d <= n; d++) for(int h = 1; h < d; h++) ans += possible[d * d - h * h]; cout << ans << '\n'; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #include <iostream> using namespace std; int possible[50000090]; int main() { int n, ans = 0; cin >> n; for(int b = 1; b <= n; b++) for(int a = 1; a <= b; a++) possible[b * b + a * a]++; for(int d = 1; d <= n; d++) for(int h = 1; h < d; h++) ans += possible[d * d - h * h]; cout << ans << '\n'; return 0; } |