-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBAEKJOON_15651
More file actions
41 lines (34 loc) · 1.06 KB
/
BAEKJOON_15651
File metadata and controls
41 lines (34 loc) · 1.06 KB
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
import java.io.*;
import java.sql.Array;
import java.util.*;
public class Main {
static StringBuilder sb =new StringBuilder();
static boolean[] c;
static int[] a;
public static void recursion(int index,int N ,int M){
if(index==M){
for(int i=0; i<M; i++){
sb.append(a[i]+" ");
}
sb.append("\n");
return;
}
for(int i=1; i<=N; i++){
a[index]=i;
recursion(index+1,N,M);
}
}
public static void main(String[] args) throws IOException {
BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out));
StringTokenizer st = new StringTokenizer(br.readLine());
int N = Integer.parseInt(st.nextToken());
int M = Integer.parseInt(st.nextToken());
c=new boolean[N+1];
a=new int[M];
recursion(0,N,M);
bw.write(sb.toString());
bw.flush();
bw.close();
}
}