Var a,b,c,d,e,f,k:integer; begin for a:=1 to 3 do for b:=0 to 9 do if (a<>b) then for c:=0 to 9 do if (c<>a)and(c<>b) then for d:=0 to 9 do if (d<>a)and(d<>b)and(d<>c) then for e:=0 to 9 do if (e<>a)and(e<>b)and(e<>c)and(e<>d) then begin k:=a*10000+b*1000+c*100+d*10+e; for f:=0 to 9 do if (f<>a)and(f<>b)and(f<>c)and(f<>d)and(f<>e) then if k+k+k=b*10000+e*1000+f*100+a*10+e then writeln('книга = ',k,' наука = ',b*10000+e*1000+f*100+a*10+e); end; end.
begin
for a:=1 to 3 do
for b:=0 to 9 do
if (a<>b) then
for c:=0 to 9 do
if (c<>a)and(c<>b) then
for d:=0 to 9 do
if (d<>a)and(d<>b)and(d<>c) then
for e:=0 to 9 do
if (e<>a)and(e<>b)and(e<>c)and(e<>d) then
begin
k:=a*10000+b*1000+c*100+d*10+e;
for f:=0 to 9 do
if (f<>a)and(f<>b)and(f<>c)and(f<>d)and(f<>e) then
if k+k+k=b*10000+e*1000+f*100+a*10+e
then writeln('книга = ',k,' наука = ',b*10000+e*1000+f*100+a*10+e);
end;
end.
Результат:
книга = 28375 наука = 85125