Advertisement
sajid161

Class - 23 : Task - 1

Dec 15th, 2024
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     int n,b;
  6.     cin>>n>>b;
  7.     vector<int>v(n);
  8.     for(int i=0;i<n;i++)
  9.     {
  10.         v[i]=i+1;
  11.     }
  12.  
  13.      int k=0;
  14.      while(!v.empty())
  15.     {
  16.         int p=(k+b-1)%v.size();
  17.         cout<<v[p]<<" ";
  18.         v.erase(v.begin()+p);
  19.           k=p;
  20.     }
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement