Skip to content

Commit

Permalink
Create S5_11866
Browse files Browse the repository at this point in the history
  • Loading branch information
RangKoon authored Jul 17, 2024
1 parent c5457be commit b1455aa
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions 진민혁/S5_11866
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import java.util.*;
import java.io.*;

public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] input = br.readLine().split(" ");
int n = Integer.parseInt(input[0]);
int k = Integer.parseInt(input[1]);
int cnt = 0;
Queue<Integer> q = new LinkedList<>();
StringBuilder sb = new StringBuilder();
sb.append("<");
for(int i=1; i<=n; i++) {
q.add(i);
}
while(q.size()>1) {
int tmp = q.peek();
q.remove();
cnt ++;
if(cnt%k == 0) {
sb.append(tmp + ", ");
}
else {
q.add(tmp);
}
}
sb.append(q.peek() + ">");
System.out.println(sb);
}
}

0 comments on commit b1455aa

Please sign in to comment.