Pagini recente » Cod sursa (job #1730770) | Cod sursa (job #236445) | Cod sursa (job #212414) | Cod sursa (job #872779) | Cod sursa (job #238934)
Cod sursa(job #238934)
program alex;
var f:text;
c:array[1..10000]of 0..1;
x,y,a,b,r,m,i,j,k,s:longint;
e:boolean;
begin
assign(f,'multiplu.in');reset(f);
readln(f,a,b);
close(f);
x:=a;
y:=b;
r:=x mod y;
while r<>0 do
begin
x:=y;
y:=r;
r:=x mod y;
end;
m:=(a*b) div y;
i:=0;
e:=false;
repeat
i:=i+1;
k:=0;
j:=i;
while j<>0 do
begin
r:=j mod 2;
k:=k+1;
c[k]:=r;
j:=j div 2;
end;
s:=0;
for j:=k downto 1 do
begin
r:=s mod m;
s:=r*10+c[j];
end;
r:=s mod m;
if r=0 then e:=true;
until e=true;
assign(f,'multiplu.out');rewrite(f);
for i:=k downto 1 do
write(f,c[i]);
close(f);
end.