We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 29ce10a commit e1f5552Copy full SHA for e1f5552
week2/BOJ_11866(요세푸스 문제 0).java
@@ -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