#include <stdio.h>

int main() {
    int n,k,rear=0;
    int num[1000000];
    scanf("%d %d",&n, &k);
    for(int j=0; j<n; j++) {
        num[j]=j+1;
        rear++;
    }
    //  뽑는거  ,넣는위치
    int front=0;
    printf("<");
    while(front!=rear) {
        //k-1번째까지 뒤로 옮김
        for(int i=0; i<k-1; i++) {
            num[rear++]=num[front++];
        }
        //빼낼숫자
        int target=num[front++];
        if(rear==front) printf("%d",target);
        else printf("%d, ",target);
    }
    printf(">");
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: