Pagini recente » Cod sursa (job #1145891) | Cod sursa (job #2415846) | Cod sursa (job #2551421) | Cod sursa (job #2984604) | Cod sursa (job #451005)
Cod sursa(job #451005)
var max,min,c,s,d,i,j:longint;
function cmmdc(a,b: longint):longint;
begin
while b<>0 do
begin
c:=a mod b;
a:=b;
b:=c;
end;
cmmdc:=a;
end;
{function prime(a,b:longint):boolean;
var k,i:longint;
begin
k:=trunc(sqrt(a));
prime:=true;
for i:=2 to k do
if a mod i=0 then
begin
if b mod i=0 then
begin
prime:=false;
break;
end;
a:=a div i;
while a mod i=0 do
a:=a div i;
end;
if (a<>1) and (b mod a=0) then prime:=false;
end;}
begin
assign(input,'mins.in');
assign(output,'mins.out');
reset(input);
rewrite(output);
readln(c,d);
if c<d then
begin
min:=c-1;
max:=d-1;
end
else
begin
min:=d-1;
max:=c-1;
end;
s:=0;
for i:=2 to min do
for j:=1 to i-1 do
if {prime(i,j)=true} cmmdc(i,j)=1 then inc(s);
s:=s*2;
for i:=min+1 to max do
for j:=1 to min do
if {prime(i,j)=true} cmmdc(i,j)=1 then inc(s);
writeln(s+1);
close(output);
end.