Cod sursa(job #3311484)

Utilizator OrhanZLTOrhan Zlatkov OrhanZLT Data 22 septembrie 2025 17:52:21
Problema Order Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.98 kb
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <cmath>
#define ll long long

using namespace std;

const ll MOD=9917;//1000000007;
const string filename="inv";
ifstream fin(filename+".in");
ofstream fout(filename+".out");
void update(vector<ll> &aib,ll val,ll pos){
    ll x=aib.size();
    while(pos<x){
        aib[pos]+=val;
        pos+=(pos&(-pos));
    }
}
ll prefsum(vector<ll> &aib,ll pos){
    ll sum=0;
    while(0<pos){
        sum+=aib[pos];
        pos-=(pos&(-pos));
    }
    return sum;
}
ll srq(vector<ll> &aib,ll a,ll b){
    return prefsum(aib,b)-prefsum(aib,a-1);
}

int main()
{
    ll n,x,y=0;
    fin>>n;
    vector<bool> v(n,true);
    for(ll i=0;i<n;i++){
        x=0;
        while(x<=i){
            y++;
            while(v[y%n]==false)y++;
            x++;

        }
        v[y%n]=false;
        cout<<y%n+1<<' ';
    }
    return 0;
}