Pagini recente » Cod sursa (job #105721) | Cod sursa (job #2052816) | Cod sursa (job #2856869) | Cod sursa (job #2095482) | Cod sursa (job #164029)
Cod sursa(job #164029)
var f,g:text;
p,a,b,k,cmmmc,aux,r:int64;
rez:array[1..20000002] of longint;
gasit:boolean;
i:longint;
begin
assign(f,'multiplu.in');reset(f);
assign(g,'multiplu.out');rewrite(g);
read(f,a,b);
p:=a*b;
while b<>0 do begin
r:=a mod b;
a:=b;
b:=r;
end;
cmmmc:=p div a;
gasit:=false;
k:=0;
a:=cmmmc;
while not gasit do begin
rez[1]:=rez[1]+1;
i:=1;
while rez[i]=2 do begin
rez[i]:=0;
rez[i+1]:=rez[i+1]+1;
i:=i+1;
end;
if i>k then k:=i;
aux:=0;
for i:=k downto 1 do
aux:=(rez[i]+aux*10) mod a;
if aux=0 then gasit:=true;
end;
for i:=k downto 1 do
write(g,rez[i]);
close(f);
close(g);
end.