这题做的很搞笑..
真得总结总结..
把方程分成两半,然后计算其中一半,存入hash.
如果枚举另一半,然后与hash表对照..并累加..
可笑的我一开始用了两个大数组来当hash..直接1对1映射累加..然后内存超了..
然后后来才想起来..只用一个hash..然后另一个来找就行了..
但是我用的大数组还是大了..
应该写一个hash才好..
于是怒了..直接map扔上去..- -
#include <iostream>
#include <map>
using namespace std;

long long result=0;
map<int,int> m;
int main()


{
int a1,a2,a3,a4,a5;
cin>>a1>>a2>>a3>>a4>>a5;

for (int i=-50;i<=50;i++)
for (int j=-50;j<=50;j++)

{
if (i==0||j==0) continue;
int x=i*i*i*a4+j*j*j*a5;
map<int,int>::iterator iter=m.find(x);
if (iter==m.end())

{
m.insert(make_pair(x,1));
}
else

{
iter->second++;
}
}

for (int i=-50;i<=50;i++)
for (int j=-50;j<=50;j++)
for (int k=-50;k<=50;k++)

{
if (i==0||j==0||k==0) continue;
int x=i*i*i*a1+j*j*j*a2+k*k*k*a3;
map<int,int>::iterator iter=m.find(-x);
if (iter!=m.end())

{
result+=iter->second;
}
}
cout<<result<<endl;
system("pause");
return 0;
}
