Cod sursa(job #2100767)

Utilizator miguelMihail Lavric miguel Data 6 ianuarie 2018 12:31:01
Problema Radix Sort Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.59 kb
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define sz size()
#define pb push_back
const ll mod = 1e9 + 7;
ll n, a, b, c;
vector <ll> v;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    ifstream fin("radixsort.in");
    ofstream fout("radixsort.out");
    fin>>n>>a>>b>>c; v.pb(b);
    for(int i=1; i<n; i++){v.pb((v[i-1]*a+b)%c);}
    sort(v.begin(), v.end());
    for(int i=0; i<n; i+=10) fout<<v[i]<<" ";
}