-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmimdo_20210129_SWEA_8457.cpp
64 lines (54 loc) · 1.25 KB
/
mimdo_20210129_SWEA_8457.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
using namespace std;
bool recursion(int init_sand, int target, int mult_sand);
int main()
{
int test_case;
cin >> test_case;
for (int tc = 1; tc <= test_case; tc++)
{
/***************/
int sandNum = 0; // 모래시계 갯수
int b = 0; // 정확한 값
int e = 0; // 오차
cin >> sandNum >> b >> e;
int cnt = 0; // count
int sand[100]; // 상점에 있는 모래시계 수
for (int i = 0; i < sandNum; i++)
{
cin >> sand[i];
}
/***************/
for (int i = 0; i < sandNum; i++)
{
int target = b - e; // 오차 범위 내 수
for (int j = 0; j < e * 2 + 1; j++)
{
// cout << "========================" << endl;
// cout << "target = " << target << endl;
// cout << "sand[" << i << "] = " << sand[i] << endl;
// cout << "========================" << endl;
if (recursion(sand[i], target, sand[i]))
{
cnt++;
break;
}
else
{
target++;
}
}
}
cout << '#' << tc <<" " << cnt << endl;
}
return 0;
}
bool recursion(int init_sand, int target, int mult_sand)
{
if (mult_sand > target)
return false;
else if (mult_sand == target)
return true;
else
recursion(init_sand, target, mult_sand + init_sand);
}