http://poj.org/problem?id=1840
/* */ /************************************************ * Author :Powatr * Created Time :2015-9-1 16:03:34 * File Name : ************************************************/ #include <cstdio> #include <algorithm> #include <iostream> #include <sstream> #include <cstring> #include <cmath> #include <string> #include <vector> #include <queue> #include <deque> #include <stack> #include <list> #include <map> #include <set> #include <bitset> #include <cstdlib> #include <ctime> using namespace std; #define lson l, mid, rt << 1 #define rson mid + 1, r, rt << 1 | 1 typedef long long ll; const int MAXN = 2e7+5e6 ; const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; short int a[MAXN]; int b[6]; int main(){ for(int i = 1; i <= 5; i++) scanf("%d", &b[i]); memset(a, 0, sizeof(a)); ll sum; 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; sum = -1*(i*i*i*b[1] + j*j*j*b[2] + k*k*k*b[3]); if(sum < 0) sum += MAXN; a[sum]++; } } } int cout = 0; for(int i = -50; i <= 50; i++){ for(int j = -50; j <= 50; j++){ if(i == 0 || j == 0) continue; sum = i*i*i*b[4] + j*j*j*b[5] ; if(sum < 0) sum += MAXN; if(a[sum]) cout+=a[sum]; } } printf("%d ", cout); return 0; }