Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- #include <ext/pb_ds/assoc_container.hpp>
- using namespace __gnu_pbds;
- typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
- #define suni ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
- #define endl "\n"
- #define mn int main()
- #define frac() cout.unsetf(ios::floatfield);cout.precision(6);cout.setf(ios::fixed,ios::floatfield);
- const int maxx=1e5+123;
- //int a[maxx];
- mn
- {
- suni;
- int n,k;
- cin>>n>>k;
- ordered_set p;
- for(int i=1; i<=n; i++)
- p.insert(i);
- int cnt=0;
- while(p.size()>0)
- {
- cnt+=k-1;
- cnt%=p.size();
- int val= *p.find_by_order(cnt);
- cout<<val<<" ";
- p.erase(val);
- cnt= p.order_of_key(val);
- }
- cout<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement