打完哈希表后记得剪枝,我噗这题数据对时间要求挺高的。
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;
const int N = 2000005;
int main()
{
// freopen("in.txt", "r", stdin);
int a, b, c, d;
int Hash[N];
while(~scanf("%d%d%d%d", &a, &b, &c, &d))
{
if(a * b > 0 && b * c > 0 && c * 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 * i * i + b * j * j + 1000000] ++;
int ans = 0;
for(int i = 1; i <= 100; i ++)
for(int j = 1; j <= 100; j ++)
ans += Hash[- c * i * i - d * j * j + 1000000];
printf("%d\n", 16 * ans);
}
return 0;
}