์๊ฐ ์ ํ | ๋ฉ๋ชจ๋ฆฌ ์ ํ | ์ ๋ต ๋น์จ |
1 ์ด | 128 MB | 53.637 % |
k ๊ฐ๋ก ์ด๋ฃจ์ด์ง ์งํฉ S ์์ 6๊ฐ์ ์ซ์๋ฅผ ์ฌ์ ์์ผ๋ก ์ถ๋ ฅํ๋ฉด ๋๋ค.
๋ฉ๋ชจ๋ฆฌ | ์๊ฐ |
1116 KB | 0 ms |
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
|
#include<cstdio>
#include<algorithm>
#include<string.h>
using namespace std;
int k;
int S[15], chk[15];
void lotto(int position, int cnt) {
if (cnt >= 6) {
for (int i = 0; i < k; i++) {
if (chk[i]) {
printf("%d ", S[i]);
}
}
printf("\n");
return;
}
for (int i = position; i < k; i++) {
if (!chk[i]) {
chk[i] = 1;
lotto(i, cnt + 1);
chk[i] = 0;
}
}
return;
}
int main() {
while(1){
scanf("%d", &k);
if (k <= 0) break;
for (int i = 0; i < k; i++) {
scanf("%d", &S[i]);
}
lotto(0, 0);
memset(S, 0, sizeof(S));
memset(chk, 0, sizeof(chk));
printf("\n");
}
return 0;
}
|
cs |
'๐ฅ PS(Problem Solving) ๐ฅ > BOJ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[BOJ] #1541 ์์ด๋ฒ๋ฆฐ ๊ดํธ (0) | 2019.09.04 |
---|---|
[BOJ] #2573 ๋น์ฐ (0) | 2019.09.04 |
[BOJ] #2667 ๋จ์ง๋ฒํธ๋ถ์ด๊ธฐ (0) | 2019.09.04 |
[BOJ] #2644 ์ด์๊ณ์ฐ (0) | 2019.09.04 |
[BOJ] #14502 ์ฐ๊ตฌ์ (0) | 2019.09.04 |
๋๊ธ