Pagini recente » Cod sursa (job #2355856) | Cod sursa (job #3226974) | Diferente pentru documentatie/arhiva-educationala intre reviziile 2 si 3 | Cod sursa (job #423936) | Cod sursa (job #1214170)
program radixsort;
var bufout:array [1..100000] of byte;
n,i:longint;
w:int64;
x,y,z:longint;
a,b: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 inc(count[a[i] mod 100000]);
for i:=1 to 99999 do count[i]:=count[i]+count[i-1];
for i:=n downto 1 do
begin
x:=a[i] mod 100000;
b[count[x]]:=a[i];
dec(count[x]);
end;
for i:=0 to 99999 do count[i]:=0;
for i:=1 to n do inc(count[b[i]div 100000]);
for i:=1 to 99999 do count[i]:=count[i]+count[i-1];
for i:=n downto 1 do
begin
x:=b[i] div 100000;
a[count[x]]:=b[i];
dec(count[x]);
end;
i:=1;
while i<=n do
begin
write(a[i],' ');
i:=i+10;
end;
close(output);
end.