-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboj10448.cpp
More file actions
51 lines (44 loc) · 998 Bytes
/
boj10448.cpp
File metadata and controls
51 lines (44 loc) · 998 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
44
45
46
47
48
49
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
using namespace std;
const int MAX = 10e+6;
const int INF = 0x66554433;
inline void Quick_IO(){
ios_base :: sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
int main(){
Quick_IO();
int t;
int num = 1;
int j = 2;
vector<int> tri;
while(num<1000){
tri.push_back(num);
num+=(j++);
}
function<bool(int)> check = [&tri](int n){
int r = lower_bound(tri.begin(), tri.end(), n) - tri.begin();
for (int i = 0; i < r; ++i) {
for (int k = 0; k <r; ++k) {
for (int l = 0; l < r; ++l) {
if(n == tri[i] + tri[k] + tri[l]) return true;
}
}
}
return false;
};
cin>>t;
while(t--){
int n;
cin>>n;
if(check(n)) cout<<1<<"\n";
else cout<<0<<"\n";
}
return 0;
}