哈希的一血
#include<iostream>
#include<cstring>
#include<cstdio>
using std::cout;
using std::endl;
const int mod = 139997;
int hash[140000];
int cot=0;
int a[140000][100];
inline void insert(int ans)
{
int he = (ans%mod+mod)%mod;
a[he][hash[he]++]=ans;
return ;
}
void search(int ans)
{
int he = (ans%mod+mod)%mod;
for(int i = 0 ; i < hash[he] ;i++)
{
if(a[he][i]==ans)
{
cot++;
}
}
return ;
}
int main()
{
int i,j;
int a1,a2,a3,a4,a5;
scanf("%d%d%d%d%d",&a1,&a2,&a3,&a4,&a5);
int ans = 0;
int k;
memset(hash,0,sizeof(hash));
memset(a,0,sizeof(a));
for(i=-50;i<=50;i++)
{
for(j=-50;j<=50;j++)
{
if(i==0||j==0)
continue;
ans = -(a1*i*i*i+a2*j*j*j);
insert(ans);
}
}
for(i=-50;i<=50;i++)
{
for(j=-50;j<=50;j++)
{
for(k=-50;k<=50;k++)
{
if(i==0||j==0||k==0)
continue;
ans = a3*i*i*i+a4*j*j*j+a5*k*k*k;
search(ans);
}
}
}
cout<<cot<<endl;
return 0;
}