program tz;
var
n,k,i,nach,pred:integer;
Function SumCifr(l:integer):integer;
s:string;
sum,i,j,err:integer;
begin
str(l, s);
sum:=0;
for i:= length(s) downto 1 do
val(s[i],j,err);
sum:=sum+j;
end;
SumCifr:=sum;
Procedure Cifri(nach,pred,k:integer);
i:integer;
for i:=nach to pred do
if SumCifr(i)=k then
Write(i, ' ');
writeln('k = ');
readln(k);
writeln('n = ');
readln(n);
if n<5 then
nach:=1;
for i:=1 to n-1 do
nach:=nach*10;
pred:=nach*10-1;
Cifri(nach,pred,k)
end
else
nach:=10000;
pred:=32767;
Cifri(nach,pred,k);
end.
program tz;
var
n,k,i,nach,pred:integer;
Function SumCifr(l:integer):integer;
var
s:string;
sum,i,j,err:integer;
begin
str(l, s);
sum:=0;
for i:= length(s) downto 1 do
begin
val(s[i],j,err);
sum:=sum+j;
end;
SumCifr:=sum;
end;
Procedure Cifri(nach,pred,k:integer);
var
i:integer;
begin
for i:=nach to pred do
if SumCifr(i)=k then
Write(i, ' ');
end;
begin
writeln('k = ');
readln(k);
writeln('n = ');
readln(n);
if n<5 then
begin
nach:=1;
for i:=1 to n-1 do
nach:=nach*10;
pred:=nach*10-1;
Cifri(nach,pred,k)
end
else
begin
nach:=10000;
pred:=32767;
Cifri(nach,pred,k);
end;
end.