-
Notifications
You must be signed in to change notification settings - Fork 0
/
로또.cc
46 lines (38 loc) · 877 Bytes
/
로또.cc
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
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int k;
vector<int> lotto, answer;
bool check[50];
void dfs() {
if (answer.size() == 6) {
for(int num : answer) {
cout << num << " ";
}
cout << '\n';
return;
}
for(int i=0; i < k; i++) {
if (!check[i] && (answer.empty() || lotto[i] > answer.back())) {
check[i] = true;
answer.push_back(lotto[i]);
dfs();
answer.pop_back();
check[i] = false;
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
while(true) {
cin >> k;
if (k == 0) break;
lotto.resize(k);
for(int i=0; i < k; i++) cin >> lotto[i];
dfs();
cout << '\n';
}
return 0;
}