import java.util.Scanner;
public class Main {
static StringBuilder sb = new StringBuilder();
static int N, M;
static int[] select;
static void rec_func(int k) {
if(k == M+1) {
for(int i=1; i<=M; i++) {
sb.append(select[i]).append(' ');
}
sb.append('\n');
}else {
int start = select[k-1];
if(start == 0) {
start = 1;
}
for(int j=start; j<=N; j++) {
select[k] = j;
rec_func(k+1);
select[k] = 0;
}
}
}
public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
N = kb.nextInt();
M = kb.nextInt();
select = new int[N+1];
rec_func(1);
System.out.print(sb);
}
}
'공부기록 > 백준' 카테고리의 다른 글
[백준] 7795번 먹을 것인가 먹힐 것인가 (0) | 2023.09.28 |
---|---|
[백준] 15650번 N과 M(2) (0) | 2023.09.27 |
[백준] 15649번 N과 M (1) (0) | 2023.09.27 |
[백준] 2775번 부녀회장이 될테야 (1) | 2023.09.27 |
[백준] 1110번 더하기 사이클 (0) | 2023.09.27 |