Time Limit: 5000MS | Memory Limit: 65536K | |
Total Submissions: 14929 | Accepted: 7329 |
Description
Input
Output
Sample Input
37 29 41 43 47
Sample Output
654
Source
#include <cstdio> #include <cmath> #include <iostream> using namespace std; int a1,a2,a3,a4,a5,ans,f[2000007],val[2000007]; bool jud[2000007]; void insert(int x) { int k=abs(x) % 1300707; while(jud[k] && f[k] != x) k++; if(!jud[k]) { jud[k]=true; f[k]=x; } val[k]++; } int Find(int x) { int k=abs(x) % 1300707; while(jud[k] && f[k] != x) k++; return(val[k]); } int main() { cin.sync_with_stdio(false); cin>>a1>>a2>>a3>>a4>>a5; for(int i=-50;i <= 50;i++) for(int j=-50;j <= 50;j++) if(i*j) insert(-(a4*i*i*i+a5*j*j*j)); for(int i=-50;i <= 50;i++) for(int j=-50;j <= 50;j++) for(int k=-50;k <= 50;k++) if(i*j*k && abs(a1*i*i*i+a2*j*j*j+a3*k*k*k) <= 2*6250000) ans+=Find(a1*i*i*i+a2*j*j*j+a3*k*k*k); cout<<ans<<endl; }