Algorithm/reporting-number/main.cc

36 lines
615 B
C++

#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
int main() {
queue<int> q;
int X, Y, K;
cin >> X >> Y >> K;
for (int i = 1; i <= X + Y; i++) {
q.push(i);
}
int count = 0;
while (q.size() > X) {
count++;
if (count == K) {
q.pop();
count = 0;
} else {
auto pin = q.front();
q.pop();
q.push(pin);
}
};
vector<int> v;
while (q.size() > 0) {
v.push_back(q.front());
q.pop();
}
sort(v.begin(), v.end());
for (int i = 0; i < v.size(); i++) {
printf("%d ", v[i]);
}
printf("\n");
}