Files
python/GESP/Mkx/YueSeFuHuan.cpp

26 lines
406 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#include <bits/stdc++.h>
using namespace std;
int n, m;
int main() {
cin >> n >> m;
queue<int> q; // stl的队列
// n个人进入队列
for (int i = 1; i <= n; i++)
q.push(i);
// 准备出队列
int cnt = 0;
while (q.size()) {
int x = q.front();
q.pop();
cnt++;
if (cnt % m)
q.push(x);
else
cout << x << " ";
}
return 0;
}