Решите: USSR+USA=REACE

0 голосов
53 просмотров

Решите: USSR+USA=REACE


Информатика (21 баллов) | 53 просмотров
Дан 1 ответ
0 голосов
Правильный ответ

Var u,s,r,a:byte;
ussr,usa,peace:integer;
begin
for u:=1 to 9 do
 for s:=0 to 9 do
  for r:=0 to 9 do
   if (u<>s)and(u<>r)and(s<>r) then
    begin
    ussr:=u*1000+s*100+s*10+r;
    for a:=0 to 9 do
     if (a<>u)and(a<>s)and(a<>r) then
      begin
      usa:=u*100+s*10+a;
      peace:=ussr+usa;
      if (peace>9999)and(peace div 100 mod 10 = a)
         and(peace div 1000 mod 10 = peace mod 10)
          then writeln(u,s,s,r,'+',u,s,a,' = ',peace);
      end;
     end;
end.

Результат:
9338+932 = 10270
9447+943 = 10390

(194k баллов)