728x90
https://www.acmicpc.net/problem/15651
// 코드
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
|
import java.util.*;
import java.io.*;
public class Main{
static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
static int[] result = null;
static int N;
static int M;
static void getResult(int x) throws Exception {
if(x == M) {
int myLen = result.length;
for(int i=0; i<myLen; i++) {
bw.write(String.valueOf(result[i]) + " ");
}
bw.newLine();
} else {
for(int i=1; i<=N; i++) {
result[x] = i;
getResult(x+1);
}
}
}
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
N = Integer.parseInt(st.nextToken());
M = Integer.parseInt(st.nextToken());
result = new int[M];
getResult(0);
br.close();
bw.flush();
bw.close();
}
}
|
cs |
반응형
'CS > 알고리즘_문제풀이(자바)' 카테고리의 다른 글
순열구하기 (0) | 2021.09.22 |
---|---|
N과 M (4) (0) | 2021.09.22 |
binary (0) | 2021.09.21 |
mountain (0) | 2021.09.21 |
1, 2, 3 더하기 (0) | 2021.09.21 |