Cod sursa(job #2702675)

Utilizator DragosC1Dragos DragosC1 Data 5 februarie 2021 14:15:12
Problema Radix Sort Scor 30
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.45 kb
#include <fstream>
#include <algorithm>
using namespace std;

int a[10000001];
int n;

int main() {
    int i, x, y, z;

    ifstream f("radixsort.in");
    f >> n >> x >> y >> z;
    f.close();

    a[0] = y % z;
    for (i = 1; i < n; i++)
        a[i] = (1LL * x * a[i - 1] + 1LL * y) % z;
    
    sort(a, a + n);

    ofstream g("radixsort.out");
    for (i = 0; i < n; i += 10)
        g << a[i] << ' ';
    g.close();
    return 0;
}