/* -*- coding: utf-8 -*- * * 800.cc: No.800 四平方定理 - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 2000; const int MAX_NN2 = MAX_N * MAX_N * 2; /* typedef */ typedef long long ll; /* global variables */ int cxy[MAX_NN2 + 1], czw[MAX_NN2 + 1]; /* subroutines */ /* main */ int main() { int n, d; scanf("%d%d", &n, &d); int nn2 = n * n * 2; for (int x = 1; x <= n; x++) for (int y = 1; y <= n; y++) cxy[x * x + y * y]++; for (int z = 1; z <= n; z++) for (int w = 1; w <= n; w++) { int k = w * w - z * z + d; if (k >= 2 && k <= nn2) czw[k]++; } ll sum = 0; for (int k = 2; k <= nn2; k++) sum += (ll)cxy[k] * czw[k]; printf("%lld\n", sum); return 0; }