'commit'
This commit is contained in:
26
GESP/Mkx/YueSeFuHuan.cpp
Normal file
26
GESP/Mkx/YueSeFuHuan.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user