Advertisement
Guest User

Untitled

a guest
Feb 6th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <list>
  3. using namespace std;
  4.  
  5. int main(){
  6.     int people;
  7.     int rounds;
  8.     cin >> people;
  9.     cin >> rounds;
  10.  
  11.     int count = 1;
  12.     list<int> guest (people, 0);
  13.     list<int>::iterator it;
  14.  
  15.     for (it = guest.begin(); it != guest.end(); it++) {
  16.         *it = count;
  17.         count++;
  18.     }
  19.  
  20.     for (int i = 0; i < rounds; i++) {
  21.         int r;
  22.         cin >> r;
  23.  
  24.         int size = guest.size();
  25.         it = guest.begin();
  26.  
  27.         for (int x = 1; x > -1; x++) {
  28.             if (x * r <= size) {
  29.                 if (x == 1) {
  30.                     advance(it, r - 1);
  31.                     it = guest.erase(it);
  32.                     it--;
  33.                 }
  34.                 else {
  35.                     advance(it, r);
  36.                     it = guest.erase(it);
  37.                     it--;
  38.                 }
  39.             }
  40.             else {
  41.                 break;
  42.             }
  43.         }
  44.     }
  45.  
  46.     for (it = guest.begin(); it != guest.end(); it++) {
  47.         cout << *it << endl;
  48.     }
  49.  
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement