-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboj11866.java
More file actions
31 lines (25 loc) · 743 Bytes
/
boj11866.java
File metadata and controls
31 lines (25 loc) · 743 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
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class boj11866 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Queue<Integer> q = new LinkedList<>();
int N = sc.nextInt();
int K = sc.nextInt();
for (int i = 1; i <= N; i++) {
q.add(i);
}
StringBuilder sb = new StringBuilder();
sb.append('<');
while (q.size() > 1) {
for (int i = 0; i < K - 1; i++) {
int num = q.poll();
q.offer(num);
}
sb.append(q.poll()).append(", ");
}
sb.append(q.poll()).append('>');
System.out.println(sb);
}
}