Cod sursa(job #1506470)

Utilizator eu3neuomManghiuc Teodor-Florin eu3neuom Data 20 octombrie 2015 18:25:18
Problema Order Scor 85
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.68 kb
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

ifstream fin("order.in");
ofstream fout("order.out");

int pos = 1;

vector < int > v;

inline void Remove(const int &value){
    if(pos + value < v.size()){
        pos += value;
        fout << v[pos] << " ";
        v.erase(v.begin() + pos);
    } else {
        pos = value - (v.size() - pos);
        pos = pos % v.size();
        fout << v[pos] << " ";
        v.erase(v.begin() + pos);
    }
}

int main(){
    int n;
    fin >> n;
    for(int i = 1; i <= n; i++){
        v.push_back(i);
    }
    for(int i = 1; i <= n; i++){
        Remove(i - 1);
    }
    return 0;
}