Var k,i1,i2,i3,i4,n:integer;
begin
readln(k);
n:=0;
for i1:=1 to 9 do
for i2:=0 to 9 do
for i3:=0 to 9 do
for i4:=0 to 9 do
if i1*i2*i3*i4=k then
begin write(i1*1000+i2*100+i3*10+i4,' '); n:=n+1; end;
writeln;
writeln('n = ',n);
end.
Пример:
20
1145 1154 1225 1252 1415 1451 1514 1522 1541 2125 2152 2215 2251 2512 2521 4115 4151 4511 5114 5122 5141 5212 5221 5411
n = 24