Pagini recente » Cod sursa (job #2494465) | Cod sursa (job #3127074) | Cod sursa (job #11104) | Cod sursa (job #988895) | Cod sursa (job #2631186)
#include <bits/stdc++.h>
using namespace std;
/***********************************************/
ifstream f("radixsort.in");
ofstream g("radixsort.out");
/***********************************************/
long long n , a , b , c;
int v[10000002];
/***********************************************/
///--------------------------------------------------------
inline void readInput()
{
f>>n>>a>>b>>c;
v[0]=b;
for(int i= 1;i< n; i++)
{
v[i] = (a*v[i-1]+b)%c;
}
}
///--------------------------------------------------------
inline void radixSort(int v[] , int dim)
{
int ind[256],aux[dim],temp;
for(int i=0; i<32; i+=8)
{
int fr[256] = {0};
for(int j=0; j<dim; j++)
{
fr[(v[j]>>i)&255]++;
aux[j] = v[j];
}
ind[0] = 0;
for(int j=1; j<256; j++)
{
ind[j] = ind[j-1] + fr[j-1];
}
for(int j=0; j<dim; j++)
{
temp = (aux[j]>>i)&255;
v[ind[temp]] = aux[j];
ind[temp]++;
}
}
}
///--------------------------------------------------------
inline void Solution()
{
radixSort(v , n);
}
///--------------------------------------------------------
inline void Output()
{
for(int i = 0; i < n;i+=10) g<<v[i]<<" ";
}
///--------------------------------------------------------
int main()
{
readInput();
Solution();
Output();
return 0;
}