題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=1496
#include <cstdio>
#include <cstring>
int hash[2001000], p[101];
int main( )
{
int a, b, c, d;
for(int i=1; i<101; i++) p[i] = i*i;
while(~scanf("%d%d%d%d", &a, &b, &c, &d)) {
int sum = 0;
if((a>0 && b>0&& c>0 && d>0) || (a<0 && b<0 && c<0 && d<0)) {
printf("0\n");
continue;
}
memset(hash,0,sizeof(hash));
for(int i=1; i<=100; i++)
for(int j=1; j<=100; j++)
hash[a*p[i] + b*p[j] + 1000000]++;
for(int i=1; i<=100; i++)
for(int j=1; j <= 100; j ++)
sum += hash[1000000 - c*p[i] - d*p[j]];
printf("%d\n", sum<<4);
}
return 0;
}