Skip to content

Commit e1f5552

Browse files
committed
BOJ_11866 : 요세푸스 문제 0
1 parent 29ce10a commit e1f5552

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import java.io.*;
2+
import java.util.*;
3+
4+
public class Main {
5+
6+
public static void main(String[] args) throws IOException {
7+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
8+
String[] input = br.readLine().split(" ");
9+
int N = Integer.parseInt(input[0]);
10+
int K = Integer.parseInt(input[1]);
11+
Queue<Integer> q = new LinkedList<>();
12+
for(int i=1; i<=N; i++) {
13+
q.offer(i);
14+
}
15+
16+
StringBuffer sb = new StringBuffer();
17+
sb.append('<');
18+
for(int i=0; i<N; i++) {
19+
for(int j=0; j<K-1; j++) {
20+
q.offer(q.poll());
21+
}
22+
sb.append(q.poll());
23+
if(i < N-1) {
24+
sb.append(", ");
25+
}
26+
}
27+
sb.append('>');
28+
System.out.println(sb);
29+
}
30+
}

0 commit comments

Comments
 (0)