-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10448.cpp
More file actions
43 lines (39 loc) · 716 Bytes
/
Copy path10448.cpp
File metadata and controls
43 lines (39 loc) · 716 Bytes
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
43
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int t, n;
bool dp[1001];
int main() {
vector<int> v;
for (int i = 1, s = 0;; i++) {
s += i;
if (s > 1000)
break;
v.push_back(s);
dp[3 * s] = true;
}
int l = v.size();
for (int i = 0; i < l; i++) {
for (int j = 0; j < l; j++) {
if (i != j && (v[i] * 2 + v[j] <= 1000))
dp[v[i] * 2 + v[j]] = true;
}
}
for (int i = 0; i < l; i++) {
for (int j = i + 1; j < l; j++) {
for (int k = j + 1; k < l; k++)
if (v[i] + v[j] + v[k] <= 1000)
dp[v[i] + v[j] + v[k]] = true;
}
}
scanf("%d", &t);
while (t--) {
scanf("%d", &n);
if (dp[n])
printf("1\n");
else
printf("0\n");
}
return 0;
}