简单来模拟一下。
#include<iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int MAX = 1000 + 1;
int num[MAX] = {0};
bool book[MAX] = { false };
int main()
{
int n, m;
cin >> n >> m;
int k = n;
int cnt = 0; int tmp = 0;
for (int i = 1; i <= n; i++) num[i] = i;
while (k)
{
//cout << cnt << endl;
tmp++;
cnt = (cnt) % n + 1;
while (book[cnt]) cnt = (cnt) % n + 1;
if (!(tmp%m)&&!book[cnt])
book[cnt] = true, k--, cout << num[cnt] << " ";
}
return 0;
}