-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ02020.java
More file actions
35 lines (32 loc) · 898 Bytes
/
J02020.java
File metadata and controls
35 lines (32 loc) · 898 Bytes
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
import java.util.*;
import java.math.*;
public class J02020 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), k = sc.nextInt();
int[] a = new int[k];
for (int i = 0; i < k; i++) {
a[i] = i+1;
}
int cnt = 0;
while (true) {
cnt ++;
for (int x : a) {
System.out.print(x + " ");
}
System.out.println("");
int i = k - 1;
while (i >= 0 && a[i] == n - k + i + 1) {
i--;
}
if (i == -1) {
break;
}
a[i]++;
for (int j = i+1;j< k;j++) {
a[j] = a[j-1] + 1;
}
}
System.out.println("Tong cong co " + cnt + " to hop");
}
}