Pagini recente » Cod sursa (job #479640) | Cod sursa (job #2068181) | Cod sursa (job #2149314) | Cod sursa (job #554791) | Cod sursa (job #2970840)
#include <bits/stdc++.h>
using namespace std;
void solve() {
size_t n, a, b, c;
cin >> n >> a >> b >> c;
array<vector<unsigned>, 512> s;
for (size_t i = 0, x = b; i < n; i++) {
s[x & 0xff].push_back(static_cast<unsigned>(x));
x = (a * x + b) % c;
}
for (unsigned i = 1; i < 4; i++) {
array<vector<unsigned>, 512> p = move(s);
for (const vector<unsigned>& v : p) {
for (unsigned x : v) {
s[(x & (0xff << (i * 8))) >> (i * 8)].push_back(x);
}
}
}
}
int main() {
#ifdef LOCAL
freopen("file.in", "r", stdin);
#else
freopen("radixsort.in", "r", stdin);
freopen("radixsort.out", "w", stdout);
#endif
ios_base::sync_with_stdio(false), cin.tie(NULL);
solve();
}