n = a^2 + b^2 + c^2 + d^2。
暴力枚举a,b,c,都是sqrt(n)级别的,然后判断d^2是否是完全平方数。
/* Telekinetic Forest Guard */
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int n, m;
inline int iread() {
int f = 1, x = 0; char ch = getchar();
for(; ch < '0' || ch > '9'; ch = getchar()) f = ch == '-' ? -1 : 1;
for(; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
return f * x;
}
int main() {
n = iread(); m = sqrt(n);
int ans = 0;
for(int i = 0; i <= m; i++) for(int j = 0; j <= m; j++) for(int k = 0; k <= m; k++) {
int t = n - i * i - j * j - k * k;
if(t < 0) break;
int st = sqrt(t);
if(st * st == t) ans++;
}
printf("%d\n", ans);
return 0;
}