Pagini recente » Cod sursa (job #2674827) | Cod sursa (job #2882736) | Cod sursa (job #1240692) | Cod sursa (job #2837485) | Cod sursa (job #70959)
Cod sursa(job #70959)
var a:array[0..110000]of integer;
n,m,i,j:int64;
z,x,k:int64;
begin
assign(input,'farfurii.in');
reset(input);
assign(output,'farfurii.out');
rewrite(output);
readln(n,k);
m:=1;
while m<n+1 do
begin
inc(m);
z:=m*(m-1) div 2;
if z>k then break;
end;
dec(m);
i:=0;
while i<n-m-1 do
begin
inc(i);
write(i,' ');
a[i]:=1;
end;
x:=m+1;
z:=x*(x-1) div 2;
z:=z-k;
if n=1 then z:=0;
if z>0 then
begin
x:=n-z;
a[x]:=1;
if x>0 then write(x,' ');
end;
i:=n+1;
while i>n-m do
begin
dec(i);
if i<1 then break;
if a[i]=1 then continue;
write(i,' ');
end;
close(output);
end.