Advertisement
momo2345

war

Sep 27th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. #include <ext/pb_ds/assoc_container.hpp>
  5. using namespace __gnu_pbds;
  6. typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
  7. #define suni ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
  8. #define endl "\n"
  9. #define mn int main()
  10. #define frac() cout.unsetf(ios::floatfield);cout.precision(6);cout.setf(ios::fixed,ios::floatfield);
  11.  
  12.  
  13. const int maxx=1e5+123;
  14. //int a[maxx];
  15. mn
  16. {
  17.     suni;
  18.     int n,k;
  19.     cin>>n>>k;
  20.     ordered_set p;
  21.     for(int i=1; i<=n; i++)
  22.         p.insert(i);
  23.     int cnt=0;
  24.     while(p.size()>0)
  25.     {
  26.         cnt+=k-1;
  27.         cnt%=p.size();
  28.         int val= *p.find_by_order(cnt);
  29.         cout<<val<<" ";
  30.         p.erase(val);
  31.         cnt= p.order_of_key(val);
  32.     }
  33.     cout<<endl;
  34. }
  35.  
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement