Pagini recente » Cod sursa (job #2230999) | Cod sursa (job #65277) | Cod sursa (job #2251916) | Cod sursa (job #1898450) | Cod sursa (job #2833998)
#include <bits/stdc++.h>
using namespace std;
ifstream in("radixsort.in");
ofstream out("radixsort.out");
long long n,A,B,C;
vector<int>ant[260],act[260];
int main()
{
in >> n >> A >> B >> C;
ant[1].push_back(B);
for (int i = 1; i < n; i++)
{
long long nr = (A * ant[1][i - 1] + B) % C;
ant[1].push_back(nr);
}
int p256 = 1;
for (int q = 0; q <= 3; q++)
{
for (int i = 0; i < 256; i++)
act[i].clear();
for (int i = 0; i < 256; i++)
for (int j = 0; j < ant[i].size(); j++)
act[(ant[i][j] / p256) & 255].push_back(ant[i][j]);
p256 *= 256;
for (int i = 0; i < 256; i++)
ant[i].clear();
for (int i = 0; i < 256; i++)
{
reverse(act[i].begin(),act[i].end());
while (act[i].size())
{
ant[i].push_back(act[i][act[i].size() - 1]);
act[i].pop_back();
}
}
}
int u = 0;
for (int i = 0; i < 256; i++)
{
for (int j = 0; j < ant[i].size(); j++)
{
u++;
if (u == 10)
u = 0;
if (u == 1)
out << ant[i][j] << " ";
}
}
return 0;
}