반응형
public class Q_1158 {
public static void main(String[] args) {
Queue<Integer> queue = new LinkedList<>();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
try {
String readLine = bufferedReader.readLine();
String[] split = readLine.split(" ");
String N = split[0];
String K = split[1];
//수 넣기
for(int i=1; i<=Integer.parseInt(N); i++) {
queue.add(i);
}
//수 빼기
System.out.print("<");
for (int i=0; i<Integer.parseInt(N)-1; i++) {
for (int j=0; j<Integer.parseInt(K)-1; j++) {
queue.add(queue.peek());
queue.remove();
}
System.out.printf("%d, ", queue.peek());
queue.remove();
}
System.out.printf("%d>", queue.peek());
} catch (IOException e) {
e.printStackTrace();
}
}
}
반응형
'Algorithm > 백준 문제풀이' 카테고리의 다른 글
백준 17298 - 오큰수(자바 구현) (0) | 2021.12.15 |
---|---|
백준 17413 - 단어 뒤집기2(자바 구현) (0) | 2021.11.15 |
백준 1406 - 에디터(자바 구현) (0) | 2021.10.13 |
백준 1874 - 스택 수열(자바 구현) (0) | 2021.09.17 |
백준 9012 - 괄호(자바 구현) (0) | 2021.09.10 |