Pagini recente » Cod sursa (job #2320307) | Cod sursa (job #627886) | Cod sursa (job #2939291) | Cod sursa (job #1378816) | Cod sursa (job #1327022)
#include<fstream>
using namespace std;
ifstream fin("radixsort.in");
ofstream o("radixsort.out");
int v[10000010],u[10001000],f[69];
int main(){
int a,b,c,n;
fin>>n>>a>>b>>c;
v[1]=b;
for(int i=2;i<=n;i++)v[i] = (a*v[i-1]+b)%c;
for(int i=0;i<32;i+=4){
for(int j=0;j<=64;j++)f[j]=0;
for(int j=1;j<=n;j++)f[(v[j]>>i)&15]++;
for(int j=1;j<=16;j++)f[j]+=f[j-1];
for(int j=n;j;j--)u[f[(v[j]>>i)&15]--]=v[j];
for(int j=n;j;j--)v[j]=u[j];
}
for(int j=1;j<=n;j+=10)o<<v[j]<<" ";
return 0;
}