Well, at least O (n ^ 4) - because the fifth variable is calculated from the previous four. And 131 ^ 4 is less than 300 million, it’s almost realistic :)
Next, we write K .. + J .. + H .. = SR ..- U .. - well, you get the idea :)
The left side may have 131 ^ 3 = 2 with a small million values. Fold in the same hash. The right side - and even less, 17 thousand. After that we find the intersections of these tables - so they are the solutions ...
Update
Here is the C ++ solution.
#include <iostream> #include <iomanip> #include <map> using namespace std; const long long K = 200, J = -300, H = 749, R = 344, U = -265, S = 1000; long long intersection(const map<long long,int>& l, const map<long long,int>& r) { long long sum = 0; auto first1 = l.begin(), last1 = l.end(); auto first2 = r.begin(), last2 = r.end(); while (first1 != last1 && first2 != last2) { if (first1->first == first2->first) { sum += first1->second*first2->second; ++first1; ++first2; } else if (first1->first < first2->first) ++first1; else ++first2; } return sum; } int main() { map<long long,int> l,r; for(long long y1 = -65; y1 <= 65; ++y1) for(long long y2 = -65; y2 <= 65; ++y2) for(long long y3 = -65; y3 <= 65; ++y3) l[K*y1*y1*y1 + J*y2*y2*y2 + H*y3*y3*y3]++; for(long long y4 = -65; y4 <= 65; ++y4) for(long long y5 = -65; y5 <= 65; ++y5) r[SR*y4*y4*y4*y4-U*y5*y5*y5*y5*y5]++; cout << intersection(l,r) << endl; }
I have about 2 seconds running. Throw on the fact that this is Python, the order (of course, that I exaggerate) is still an hour away ...