You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
python/TangDou/KaoShi/约瑟夫环蓝桥国赛版.cpp

44 lines
768 B

2 years ago
#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;
}