-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.cpp
42 lines (38 loc) · 1.06 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Author : Qi Zhang
// Date : 2019-03-30
#include <bits/stdc++.h>
using namespace std;
const int N = 50, MAX = N * N * N * N * 4 + 1;
short H[MAX + 7];
int main(){
int a, b, c, d, e;
cin >> a >> b >> c >> d >> e;
memset(H, 0, sizeof H);
for (int i = -N; i <= N; ++i) {
if(i == 0) continue;
int p = a * i * i * i;
for (int j = -N; j <= N; ++j) {
if(j == 0) continue;
int left = -(p + b * j * j * j);
if(left < 0) left = left + MAX;
H[left]++;
}
}
int res = 0;
for (int i = -N; i <= N; ++i) {
if(i == 0) continue;
int p = c * i * i * i;
for(int j = -N; j <= N; ++j) {
if(j == 0) continue;
int q = p + d * j * j * j;
for (int k = -N; k <= N; ++k) {
if(k == 0) continue;
int right = q + e * k * k * k;
if(right > MAX / 2) continue;
if(right < 0) right += MAX;
res += H[right];
}
}
}
cout << res << endl;
}