Cod sursa(job #1183437)
| Utilizator | Data | 9 mai 2014 06:35:36 | |
|---|---|---|---|
| Problema | Radix Sort | Scor | 30 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.44 kb |
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
freopen("radixsort.in", "r", stdin);
freopen("radixsort.out", "w", stdout);
int n;
cin >> n;
int x, y, z;
cin >> x >> y >> z;
vector<int> a(n);
a[0] = y;
for (int i = 1; i < n; i++) {
a[i] = (x*a[i-1]+y)%z;
}
sort(a.begin(), a.end());
for (int i = 0; i < n; i += 10) {
printf("%d ", a[i]);
}
printf("\n");
return 0;
}
