It is possible to simplify the equation to a*x1^2+b*x2^2=-(c*x3^2+d*x4^2) first.
And then use a hash table to put the left side of the equation in a two-tiered loop to save the value.
Finally, we find the number of values of the left function with the right side by two loops and accumulate the answer
The specific details of the reference code
#include <iostream> #include <cstring> #include <cstdio>using namespace std;const int Size = 50*100*100 The first two largest values of the *2;//equation are int hash[2*size+10];int main () {int A, B, C, D; int arr[101]; for (int i=1; i<101; i++) arr[i]=i*i;//xi^2 This also includes the-I while (cin>>a>>b>>c>& GT;D) {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 (int i=1, i<101; i++) for (int j=1; j<101; j + +) hash[a*arr[i]+b*arr[ j]+1000000]++; int ans=0; for (int i=1, i<101; i++) for (int j=1; j<101; j + +) ans+=hash[-(C*arr[i] +D*ARR[J]) +1000000]; cout<< (ans<<4) <<endl;//because for each xi^2 Xi has positive and negative values so the total outcome scheme should be multiplied by 2^4} return 0 on the above basis;}
"Turn" hdu-1496-equations: skillfully use hash