import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;
class Main{
static int N,K;
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer();
String[] str = bf.readLine().split(" ");
N = Integer.parseInt(str[0]);
K = Integer.parseInt(str[1]);
sb.append("<");
Queue<Integer> que = new ArrayDeque<Integer>();
for (int i = 1; i <= N; i++) {
que.offer(i);
}
while (!que.isEmpty()) {
for (int i = 0; i < K-1; i++) {
que.offer(que.poll());
}
if(que.size()>1) {
sb.append(que.poll()).append(", ");
}
else {
sb.append(que.poll()).append(">");
}
}
System.out.println(sb.toString());
}
}
import java.io.*;
import java.util.*;
public class Main {
static int N, K;
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
N = Integer.parseInt(st.nextToken());
K = Integer.parseInt(st.nextToken());
Queue<Integer> queue = new ArrayDeque<>();
for(int i = 1; i <= N; i++){
queue.offer(i);
}
StringBuilder sb = new StringBuilder();
sb.append("<");
while(!queue.isEmpty()){
for (int i = 0; i < K - 1; i++) {
queue.offer(queue.poll());
}
int out = queue.poll();
sb.append(out).append(", ");
}
sb.delete(sb.length()-2, sb.length());
sb.append(">");
System.out.print(sb);
}
}
문자열 출력이 더 성가셨던 문제