代码如下:
cpp
#include <iostream>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
bool people[105] = {true};
for (int i = 1; i <= n; i++) {
people[i] = true;
}
int count = 0;
int num = 0;
int x = 0;
while (count < n) {
x++;
if (x > n) {
x = 1;
}
if (people[x] == true) {
num++;
if (num == m) {
cout << x << " ";
people[x] = false;
count++;
num = 0;
}
}
}
return 0;
}
网站链接:https://bas.ssoier.cn/problem_show.php?pid=3345
创作不易,给个关注吧🦀🦀