#include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> // #include <ext/rope> using namespace std; // using namespace __gnu_pbds; typedef long long ll; typedef unsigned long long ull; typedef unsigned int uint; typedef long double ld; template <class T> using VV = vector<vector<T>>; using VI = vector<int>; using VVI = vector<vector<int>>; using VL = vector<long long>; using VVL = vector<vector<long long>>; using VC = vector<char>; using VVC = vector<vector<char>>; using VB = vector<bool>; using VVB = vector<vector<bool>>; using VD = vector<double>; using VVD = vector<vector<double>>; using PII = pair<int, int>; using PLL = pair<long long, long long>; using PIL = pair<int, long long>; using PLI = pair<long long, int>; using VPII = vector<pair<int, int>>; using VPLL = vector<pair<long long, long long>>; #define LINE '\n' #define SPACE ' ' #define PB push_back #define FOR(i, a, b) for (int i = (a); i < (int(b)); i++) #define FORE(i, a, b) for (int i = (a); i <= (int)((b)); i++) #define ALL(x) x.begin(), x.end() #define RALL(x) x.rbegin(), x.rend() #define sq(a) ((a) * (a)) #define sz(x) ((int)x.size()) #define fastio() \ ios_base::sync_with_stdio(false); \ cin.tie(nullptr); \ cout.tie(nullptr) #define debug(x) cerr << #x << " = " << x << endl; const ll MOD = 1e9 + 7; template <class T> inline void maxi(T &a, T b) { a = max(a, b); } template <class T> inline void mini(T &a, T b) { a = min(a, b); } template <class T> inline void addi(T &a, T b) { a = (a + b) % MOD; } template <class T> inline void subi(T &a, T b) { a = (a - b + MOD) % MOD; } template <class T> inline T add(T a, T b) { return (a + b) % MOD; } template <class T> inline T sub(T a, T b) { return (a - b + MOD) % MOD; } template <class T> inline T mul(T a, T b) { return ((a % MOD) * (b % MOD)) % MOD; } constexpr ll binpow(ll a, ll b, ll mod) { ll res = 1; while (b > 0) { if (b & 1) { res = (res * a) % mod; } a = (a * a) % mod; b >>= 1; } return res; } const int INF = 1e9; const int MAX_N = 1e5 + 3; void solve() { int n; cin >> n; VL cter(n * n * 3 + 500, 0); ll ans = 0; for(ll d = 1; d <= n; d++) { for(ll c = 1; c < d; c++) { ans += cter[sq(d) - sq(c)]; } for(ll a = 1; a <= d; a++) { cter[sq(d) + sq(a)]++; } } cout << ans << LINE; } int main() { fastio(); solve(); }
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | #include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> // #include <ext/rope> using namespace std; // using namespace __gnu_pbds; typedef long long ll; typedef unsigned long long ull; typedef unsigned int uint; typedef long double ld; template <class T> using VV = vector<vector<T>>; using VI = vector<int>; using VVI = vector<vector<int>>; using VL = vector<long long>; using VVL = vector<vector<long long>>; using VC = vector<char>; using VVC = vector<vector<char>>; using VB = vector<bool>; using VVB = vector<vector<bool>>; using VD = vector<double>; using VVD = vector<vector<double>>; using PII = pair<int, int>; using PLL = pair<long long, long long>; using PIL = pair<int, long long>; using PLI = pair<long long, int>; using VPII = vector<pair<int, int>>; using VPLL = vector<pair<long long, long long>>; #define LINE '\n' #define SPACE ' ' #define PB push_back #define FOR(i, a, b) for (int i = (a); i < (int(b)); i++) #define FORE(i, a, b) for (int i = (a); i <= (int)((b)); i++) #define ALL(x) x.begin(), x.end() #define RALL(x) x.rbegin(), x.rend() #define sq(a) ((a) * (a)) #define sz(x) ((int)x.size()) #define fastio() \ ios_base::sync_with_stdio(false); \ cin.tie(nullptr); \ cout.tie(nullptr) #define debug(x) cerr << #x << " = " << x << endl; const ll MOD = 1e9 + 7; template <class T> inline void maxi(T &a, T b) { a = max(a, b); } template <class T> inline void mini(T &a, T b) { a = min(a, b); } template <class T> inline void addi(T &a, T b) { a = (a + b) % MOD; } template <class T> inline void subi(T &a, T b) { a = (a - b + MOD) % MOD; } template <class T> inline T add(T a, T b) { return (a + b) % MOD; } template <class T> inline T sub(T a, T b) { return (a - b + MOD) % MOD; } template <class T> inline T mul(T a, T b) { return ((a % MOD) * (b % MOD)) % MOD; } constexpr ll binpow(ll a, ll b, ll mod) { ll res = 1; while (b > 0) { if (b & 1) { res = (res * a) % mod; } a = (a * a) % mod; b >>= 1; } return res; } const int INF = 1e9; const int MAX_N = 1e5 + 3; void solve() { int n; cin >> n; VL cter(n * n * 3 + 500, 0); ll ans = 0; for(ll d = 1; d <= n; d++) { for(ll c = 1; c < d; c++) { ans += cter[sq(d) - sq(c)]; } for(ll a = 1; a <= d; a++) { cter[sq(d) + sq(a)]++; } } cout << ans << LINE; } int main() { fastio(); solve(); } |