-
Notifications
You must be signed in to change notification settings - Fork 1
/
1158
37 lines (32 loc) · 905 Bytes
/
1158
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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Deque;
import java.util.LinkedList;
import java.util.Stack;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
StringBuilder sb = new StringBuilder();
Deque<Integer> que = new LinkedList<>();
int N = Integer.parseInt(st.nextToken());
int K = Integer.parseInt(st.nextToken());
for(int i=1;i<=N;i++)
que.add(i);
sb.append("<");
for(int i=0;i<N;i++) {
for(int j=0;j<K-1;j++) {
int value = que.poll();
que.offer(value);
}
if(i==N-1)
sb.append(que.poll());
else
sb.append(que.poll()+", ");
}
sb.append(">");
System.out.println(sb);
}
}