天天看點

hash例

hash例
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+10,d=5e5;
int pin[101];
int hash[2000003];
int main()
{
	int a,b,c,d;
	int i,j,sum;
	for(i=1;i<101;i++)
	pin[i]=i*i;
	while(scanf("%d%d%d%d",&a,&b,&c,&d)==4)
	{
		if((a>0&&b>0&&c>0&&d>0)||(a<0&&b<0&&c<0&&d<0))
		{
			cout<<0<<endl;
			continue;
		}
		memset(hash,0,sizeof(hash));
		for(i=1;i<=100;j++)
		for(j=1;j<=100;j++)
		hash[a*pin[i]+b*pin[j]+1000000]++;
		sum=0;
		for(i=1;i<=100;i++)
		for(j=1;j<=100;j++)
		sum+=hash[-(c*pin[i]+d*pin[j])+1000000];
		cout<<sum*16<<endl;
	}
	return 0;
}