Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <list>
- using namespace std;
- int main(){
- int people;
- int rounds;
- cin >> people;
- cin >> rounds;
- int count = 1;
- list<int> guest (people, 0);
- list<int>::iterator it;
- for (it = guest.begin(); it != guest.end(); it++) {
- *it = count;
- count++;
- }
- for (int i = 0; i < rounds; i++) {
- int r;
- cin >> r;
- int size = guest.size();
- it = guest.begin();
- for (int x = 1; x > -1; x++) {
- if (x * r <= size) {
- if (x == 1) {
- advance(it, r - 1);
- it = guest.erase(it);
- it--;
- }
- else {
- advance(it, r);
- it = guest.erase(it);
- it--;
- }
- }
- else {
- break;
- }
- }
- }
- for (it = guest.begin(); it != guest.end(); it++) {
- cout << *it << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement