Cod sursa(job #1373400)
Utilizator | Data | 4 martie 2015 18:25:42 | |
---|---|---|---|
Problema | Radix Sort | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.48 kb |
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int n,a,b,c,pre;
std::vector<int> x;
int main()
{
freopen("radixsort.in","r",stdin);
freopen("radixsort.out","w",stdout);
scanf("%d %d %d %d",&n,&a,&b,&c);
x.push_back(b);
pre = b;
for(int i=2;i<=n;++i)
{
pre = (a*pre+b)%c;
x.insert(upper_bound(x.begin(),x.end(),pre),pre);
}
for(int i=0;i<x.size();i+=10)printf("%d ",x[i]);
return 0;
}