您的位置:首页 > 其它

HDU 1496 Equations

2013-10-09 23:49 211 查看
题目链接: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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: