Pagini recente » Cod sursa (job #1411012) | Cod sursa (job #2439580) | Cod sursa (job #840335) | Cod sursa (job #2737270) | Cod sursa (job #2416298)
#include <bits/stdc++.h>
#define nm 10000010
#define buckets 257
using namespace std;
ifstream in("radixsort.in");
ofstream out("radixsort.out");
int n, a, b, c;
int v[nm];
deque < int > coada[buckets];
void solve(int &n)
{
int x,j,zz,i;
for(x = 0; x < 4; x++)
{
for( j = 1; j <= n; j++)
{
int y = (v[j] >> (8 * x)) & 255;
coada[y].push_back(v[j]);
}
for( zz = 0,i = 0; i < 256; i++)
while(!coada[i].empty())
{
v[++zz] = coada[i].front();
coada[i].pop_front();
}
}
}
int main()
{
int i;
in >> n >> a >> b >> c;
v[1] = b;
for(i = 2; i <= n; i++)
v[i] = (1LL * a * v[i - 1] + b) % c;
solve(n);
for(i = 1; i <= n; i+= 10)
out << v[i] <<' ';
return 0;
}