-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2659_십자카드 문제.cpp
96 lines (77 loc) · 1.58 KB
/
2659_십자카드 문제.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int arr[9] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int combination[4] = { 0, };
int Min;
int cnt = 0;
vector<int> clockNum;
int makeNumber(int arr[])
{
return 1000 * arr[0] + 100 * arr[1] + 10 * arr[2] + arr[3];
}
int findMin(vector<int> numArr)
{
int result = 100000;
for (int i = 0; i < 4; i++)
{
if (numArr[i] < result)
result = numArr[i];
}
return result;
}
int makeClockNum(int numArr[])
{
int tempNum[4];
vector<int> createdNumbers;
createdNumbers.push_back(makeNumber(numArr));
tempNum[0] = numArr[1];
tempNum[1] = numArr[2];
tempNum[2] = numArr[3];
tempNum[3] = numArr[0];
createdNumbers.push_back(makeNumber(tempNum));
tempNum[0] = numArr[2];
tempNum[1] = numArr[3];
tempNum[2] = numArr[0];
tempNum[3] = numArr[1];
createdNumbers.push_back(makeNumber(tempNum));
tempNum[0] = numArr[3];
tempNum[1] = numArr[0];
tempNum[2] = numArr[1];
tempNum[3] = numArr[2];
createdNumbers.push_back(makeNumber(tempNum));
return findMin(createdNumbers);
}
void comb(int depth)
{
if (depth == 4)
{
clockNum.push_back(makeClockNum(combination));
}
else
{
for (int i = 0; i < 9; i++)
{
combination[depth] = arr[i];
comb(depth + 1);
}
}
}
int main(void)
{
int initNum[4];
for (int i = 0; i < 4; i++)
cin >> initNum[i];
Min = makeClockNum(initNum);
comb(0);
sort(clockNum.begin(), clockNum.end());
clockNum.erase(unique(clockNum.begin(), clockNum.end()), clockNum.end());
for (int i = 0; i < clockNum.size(); i++)
{
if (clockNum[i] <= Min)
cnt++;
}
cout << cnt;
return 0;
}