728x90
반응형

package BAEKJOON.Silver.Ⅲ;
import java.util.Scanner;
public class NO15650_2 {
static int n;
static int m;
static int[] arr;
public static void DFS(int a, int depth) {
if (depth == m) {
for (int i = 0; i < m; i++) {
System.out.print(arr[i] + " ");
}
System.out.println();
} else {
for (int i = a; i <= n; i++) {
arr[depth] = i;
DFS(i + 1, depth + 1);
}
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
m = sc.nextInt();
arr = new int[m];
DFS(1, 0);
}
}
728x90
반응형
'Algorithm & SQL > BAEKJOON' 카테고리의 다른 글
| 백준 JAVA 11279 최대 힙 (0) | 2022.07.29 |
|---|---|
| 백준 JAVA 1697 숨바꼭질 (0) | 2022.07.28 |
| 백준 JAVA 15651 N과 M(3) (0) | 2022.07.26 |
| 백준 JAVA 15649 N과 M(1) (0) | 2022.07.26 |
| 백준 JAVA 11866 요세푸스 문제0 (0) | 2022.07.21 |
댓글