随便dp。(我是不会告诉你只是为了500题纪念的)。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int read()
{
char ch=getchar();int f=0;
while(ch<'0'||ch>'9')ch=getchar();
while(ch>='0'&&ch<='9'){f=(f<<1)+(f<<3)+ch-'0';ch=getchar();}
return f;
}
int f[5][10005];
int n;
int main()
{
n=read();
f[0][0]=1;
for(int l=1;l<=4;l++)
{
for(int i=1;i<=n;i++)
{
for(int j=0;j*j<=i;j++)
{
f[l][i]+=f[l-1][i-j*j];
}
}
}
printf("%d",f[4][n]+f[3][n]+f[2][n]+f[1][n]);
return 0;
}