-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBAEKJOON_1158
More file actions
39 lines (32 loc) · 1.07 KB
/
BAEKJOON_1158
File metadata and controls
39 lines (32 loc) · 1.07 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
import java.io.*;
import java.util.*;
public class Main {
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 K = Integer.parseInt(st.nextToken());
StringBuilder sb = new StringBuilder();
Queue<Integer> q = new LinkedList<>();
// N명의사람 K번째 사람 제거
for(int i=1; i<=N; i++){
q.offer(i);
}
//<3, 6, 2, 7, 5, 1, 4>
sb.append("<");
while(!q.isEmpty()){
for(int i=0; i<K-1; i++){
q.offer(q.poll());
}
if(q.size()>1) {
sb.append(q.poll() + ", ");
}else{
sb.append(String.valueOf(q.poll())+">");
}
}
bw.write(sb.toString());
bw.flush();
bw.close();
}
}