#include <iostream>
#include <string.h>
using namespace std;
short hash[37500001];
int main()
{
memset(hash,0,sizeof(hash));
int a1,a2,a3,a4,a5;
int sum,sum1;
while(cin>>a1>>a2>>a3>>a4>>a5)
{
for(int x1=-50;x1<=50;x1++)
{
if(!x1)
continue;
for(int x2=-50;x2<=50;x2++)
{
if(!x2)
continue;
sum=(a1*x1*x1*x1+a2*x2*x2*x2);
sum+=18750000;
//sum=(a1*x1*x1*x1 + a2*x2*x2*x2)*(-1);
// if(sum<0)
// sum+=25000000;
hash[sum]++;
}
}
int sol=0;
for(int x3=-50;x3<=50;x3++)
{
if(!x3)
continue;
for (int x4=-50;x4<=50;x4++)
{
if(!x4)
continue;
for (int x5=-50;x5<=50;x5++)
{
if(!x5)
continue;
sum1=(a3*x3*x3*x3+a4*x4*x4*x4+a5*x5*x5*x5)*(-1);
sum1+=18750000;
// sum1=a3*x3*x3*x3 + a4*x4*x4*x4 + a5*x5*x5*x5;
//if(sum1<0)
// sum1+=25000000;
if(hash[sum1])
sol+=hash[sum1];
}
}
}
cout<<sol<<endl;
}
return 0;
}
原来网上代码数组是开25000000的,但是这样在第二个FOR循环sum会冲突啊 改成37500000就MLE了 我也不懂为什么可以只开25000000的
poj1840
最新推荐文章于 2021-10-05 20:45:04 发布