#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
int main()
{
int n,k;
scanf("%d %d",&n,&k);
queue<int> q;
for(int i=1; i<=n; i++)
{
q.push(i);
}
while(!q.empty())
{
for(int i=0; i<k-1; i++)
{
int rt=q.front();
q.pop();
q.push(rt);
}
printf("%d ",q.front());
q.pop();
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: