Pagini recente » Cod sursa (job #2562240) | Cod sursa (job #3131072) | Cod sursa (job #892644) | Cod sursa (job #1381536) | Cod sursa (job #115258)
Cod sursa(job #115258)
program multiplu;
const v:array[0..9]of byte=(0,1,5,7,5,0,5,3,5,9);
var a,b:integer;
sol,m,i:int64;
f:text;
function cmmdc(x,y:integer):longint;
begin
while x<>y do
if x>y then
x:=x-y
else
y:=y-x;
cmmdc:=x
end;
function cmmmc(x,y:integer):longint;
begin
cmmmc:=(x*y) div cmmdc(x,y)
end;
function gata(x:int64):boolean;
var ok:boolean;
begin
ok:=true;
repeat
if (x mod 10<>0) and (x mod 10<>1) then
ok:=false;
x:=x div 10
until not ok or (x=0);
gata:=ok
end;
begin
assign(f,'multiplu.in'); reset(f);
readln(f,a,b);
close(f);
m:=cmmmc(a,b);
i:=v[m mod 10];
sol:=m;
if not gata(sol) then
repeat
i:=i+10;
sol:=m*i
until gata(sol);
assign(f,'multiplu.out'); rewrite(f);
writeln(f,sol);
close(f)
end.