26 lines
406 B
C++
26 lines
406 B
C++
#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;
|
|
} |