hash

#include <stdio.h>
#include <memory.h>
short hash[25000001];
int main()
{
	int a1,a2,a3,a4,a5,x1,x2,x3,x4,x5;
	while(scanf("%d",&a1)!=EOF)
	{
		memset(hash,0,sizeof(hash));
		int max=0;
		scanf("%d %d %d %d",&a2,&a3,&a4,&a5);
		int sum1;
		for(x1=-50;x1<=50;x1++)
		{
			if(!x1) continue;
			for(x2=-50;x2<=50;x2++)
			{
				if(!x2) continue;
				sum1=a1*x1*x1*x1+a2*x2*x2*x2;
				sum1=-sum1;
				sum1=sum1+12500000;//关键字key

				hash[sum1]++;//直接定址法
			}
		}

		int sum2;
		for(x3=-50;x3<=50;x3++)
		{
			if(!x3) continue;
			for(x4=-50;x4<=50;x4++)
			{
				if(!x4) continue;
				for(x5=-50;x5<=50;x5++)
				{
					if(!x5) continue;
					sum2=a3*x3*x3*x3+a4*x4*x4*x4+a5*x5*x5*x5;
			        if(sum2<-12500000||sum2>12500000) continue;
					sum2=sum2+12500000;
					if(hash[sum2]) max+=hash[sum2];
			
				}
			}
		}
		printf("%d\n",max);
	}
}


 

posted on 2012-06-16 20:13  lishimin_come  阅读(112)  评论(0编辑  收藏  举报