Pagini recente » Cod sursa (job #287639) | Cod sursa (job #2189890) | Cod sursa (job #1702549) | Cod sursa (job #1121889) | Cod sursa (job #1240830)
program radixsort;
var bufout:array [1..100000] of byte;
n,i:longint;
w:qword;
x,y,z:longint;
a,b,c:array[1..10000000] of longint;
count:array[0..99999] of longint;
begin
assign(input,'radixsort.in');
reset(input);
assign(output,'radixsort.out');
rewrite(output);
settextbuf(output,bufout);
w:=1;
readln(n,x,y,z);
a[1]:=y;
for i:=2 to n do a[i]:=(w*x*a[i-1]+y)mod z;
for i:=1 to n do
begin
c[i]:=a[i]mod 100000;
inc(count[c[i]]);
end;
for i:=1 to 69999 do count[i]:=count[i]+count[i-1];
for i:=n downto 1 do
begin
b[count[c[i]]]:=a[i];
dec(count[c[i]]);
end;
for i:=0 to 69999 do count[i]:=0;
for i:=1 to n do
begin
c[i]:=b[i]div 100000;
inc(count[c[i]]);
end;
for i:=1 to 69999 do count[i]:=count[i]+count[i-1];
for i:=n downto 1 do
begin
a[count[c[i]]]:=b[i];
dec(count[c[i]]);
end;
i:=1;
while i<=n do
begin
write(a[i],' ');
i:=i+10;
end;
close(output);
end.