-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10448.cpp
More file actions
59 lines (55 loc) · 818 Bytes
/
10448.cpp
File metadata and controls
59 lines (55 loc) · 818 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
50
51
52
53
54
55
56
57
58
59
// 10448. 유레카 이론
// 2019.05.22
// 브루트 포스
#include<iostream>
using namespace std;
int n;
bool visit[46];
int d[46];
int ans;
void Find(int n, int cnt)
{
// 3개의 수를 모두 골랐을 때
if (cnt == 3)
{
// 합으로 표현될 수 있다면
if (n == 0)
{
ans = true;
return;
}
else
{
return;
}
}
// 3개를 선택하는 과정
for (int i = 1; i < 45; i++)
{
if (n - d[i] >= 0)
{
Find(n - d[i], cnt + 1);
}
}
}
int main()
{
int a = 1;
// 삼각수를 만드는 과정
// 44가 문제의 범위에서 표현될 수 있는 가장 큰 수 이다(990)
d[1] = 1;
for (int i = 2; i < 45; i++)
{
d[i] = d[i - 1] + i;
}
int t;
cin >> t;
for (int i = 0; i < t; i++)
{
ans = false;
cin >> n;
Find(n, 0);
cout << ans << endl;
}
return 0;
}