Pagini recente » Cod sursa (job #2461345) | Cod sursa (job #692351) | Cod sursa (job #785000) | Cod sursa (job #2001399) | Cod sursa (job #1179346)
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <cmath>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <stack>
#include <algorithm>
#include <list>
#include <bitset>
#include <ctime>
#include <cassert>
#include <iomanip>
using namespace std;
const string file = "radixsort";
const string inputF = file + ".in";
const string outputF = file + ".out";
const double epsilon = 1e-7;
#define LL long long
#define ULL unsigned long long
#define MOD1 666013
#define MOD2 666019
#define MOD3 1999999973
#define base 73
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> ii;
typedef pair<long long, long long> ll;
typedef vector<ii> vii;
typedef vector<ll> vll;
#define all(V) V.begin(), V.end()
#define allr(V) V.rbegin(), V.rend()
#define for_c_it(container, it) for (auto it : container)
#define present(container, element) (container.find(element) != container.end())
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define zeroes(x) ((x ^ (x - 1)) & x)
#define printC(C) for (auto x:C) { cout << x << ' '; } cout << '\n';
int N, A, B, C;
vi V, fr(2), TT;
deque<int> bucket[2][256];
void solve(vi &V) {
int i, k;
for (auto x:V) {
bucket[0][x&0xff].pb(x);
}
for (i = 0; i < 256; ++i) {
while (!bucket[0][i].empty()) {
int x = bucket[0][i].front();
bucket[1][(x&0xff00) >> 8].pb(x);
bucket[0][i].pop_front();
}
}
for (i = 0; i < 256; ++i) {
while (!bucket[1][i].empty()) {
int x = bucket[1][i].front();
bucket[0][(x&0xff0000) >> 16].pb(x);
bucket[1][i].pop_front();
}
}
for (i = 0; i < 256; ++i) {
while (!bucket[0][i].empty()) {
int x = bucket[0][i].front();
bucket[1][(x&0xff000000) >> 24].pb(x);
bucket[0][i].pop_front();
}
}
k = 0;
for (i = 0; i < 256; ++i) {
while (!bucket[1][i].empty()) {
V[k++] = bucket[1][i].front();
bucket[1][i].pop_front();
}
}
}
int main() {
#ifndef INFOARENA
freopen("input.txt", "r", stdin);
#else
freopen(inputF.c_str(), "r", stdin);
freopen(outputF.c_str(), "w", stdout);
#endif
int i;
scanf("%d %d %d %d", &N, &A, &B, &C);
V.resize(N);
V[0] = B;
for (i = 1; i < N; ++i) {
V[i] = (1LL * A * V[i - 1] + B) % C;
}
solve(V);
for (i = 0; i < N; i += 10) {
printf("%d ", V[i]);
}
return 0;
}