-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path16674.cpp
More file actions
57 lines (54 loc) · 768 Bytes
/
16674.cpp
File metadata and controls
57 lines (54 loc) · 768 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
// 16674. 2018년을 되돌아보며
// 2019.08.08
// 구현
#include<iostream>
using namespace std;
int num[10];
bool check()
{
for (int i = 0; i < 10; i++)
{
if (num[i] > 0)
{
if (i != 0 && i != 2 && i != 1 && i != 8)
{
return false;
}
}
}
return true;
}
int main()
{
int n;
cin >> n;
while (n > 0)
{
num[n % 10]++;
n /= 10;
}
// 관련 없는 수
if (!check())
{
cout << 0 << endl;
}
else
{
// 묶여있는 수
if ((num[2] == num[0] && num[0] == num[1] && num[1] == num[8] && num[8] == num[2]))
{
cout << 8 << endl;
}
// 밀접한 수
else if (num[2] != 0 && num[0] != 0 && num[1] != 0 && num[8] != 0)
{
cout << 2 << endl;
}
// 관련있는 수
else
{
cout << 1 << endl;
}
}
return 0;
}