Files
python/TangDou/KaoShi/约瑟夫环蓝桥国赛版.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

44 lines
768 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
/*
测试用例I:
5 3 3
答案:
2 4 5 7 8
测试用例II
5 4 3
5 7 8 1 2
这个测试用例可以看出由小到大排序的意义。
*/
using namespace std;
const int N = 1010;
int a[N], al;
int main() {
int x, y, k;
cin >> x >> y >> k;
queue<int> q;
int cnt = 0;
for (int i = 1; i <= x + y; i++) q.push(i);
while (q.size() > x) {
auto t = q.front();
q.pop();
cnt++;
if (cnt % k > 0)
q.push(t);
else
cnt = 0;
}
while (q.size()) {
auto t = q.front();
q.pop();
a[al++] = t;
}
sort(a, a + al);
for (int i = 0; i < al; i++) cout << a[i] << " ";
return 0;
}