Skip to content

Commit c5dd530

Browse files
committed
N과M(6) 1H
1 parent ae3aa29 commit c5dd530

File tree

5 files changed

+71
-0
lines changed

5 files changed

+71
-0
lines changed

week3/.idea/.gitignore

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

week3/.idea/material_theme_project_new.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

week3/.idea/vcs.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package N과M_6.dlwldn30;
2+
3+
import java.io.*;
4+
import java.util.*;
5+
6+
public class Main {
7+
static int N, M;
8+
static int[] arr;
9+
static List<Integer> output = new ArrayList<>();
10+
static StringBuilder sb = new StringBuilder();
11+
public static void main(String[] args) throws IOException {
12+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
13+
14+
// 입력
15+
StringTokenizer st = new StringTokenizer(br.readLine());
16+
N = Integer.parseInt(st.nextToken());
17+
M = Integer.parseInt(st.nextToken());
18+
19+
arr = new int[N];
20+
st = new StringTokenizer(br.readLine());
21+
for (int i = 0; i < N; i++) {
22+
arr[i] = Integer.parseInt(st.nextToken());
23+
}
24+
25+
Arrays.sort(arr); // 사전순 출력을 위해 정렬
26+
27+
solve(0, 0);
28+
29+
System.out.print(sb);
30+
}
31+
32+
static void solve(int start, int depth) {
33+
if (depth == M) {
34+
for (int num : output) {
35+
sb.append(num).append(' ');
36+
}
37+
sb.append('\n');
38+
return;
39+
}
40+
41+
for (int i = start; i < N; i++) {
42+
output.add(arr[i]);
43+
solve(i + 1, depth + 1);
44+
output.remove(output.size() - 1);
45+
}
46+
}
47+
}
48+
49+

week3/brute_force/블랙잭/dlwldn30/Main.java

Whitespace-only changes.

0 commit comments

Comments
 (0)