Pagini recente » Cod sursa (job #1038686) | Cod sursa (job #535872) | Cod sursa (job #1351242) | Cod sursa (job #848658) | Cod sursa (job #579318)
Cod sursa(job #579318)
const cmax=1000000;
var f,ok:array[1..cmax]of byte;
x,y,max,min,i,j:longword;
sol,aux,min1,max1,aux1:qword;
begin
assign(input,'mins.in');reset(input);
readln(x,y);dec(x);dec(y);
close(input);
if x>y then begin max:=x;min:=y;end else begin max:=y;min:=x;end;
for i:=2 to min do
if f[i]=0 then
begin
j:=i;
while j<=min do
begin
inc(f[j]);
inc(j,i);
end;
end;
min1:=min;max1:=max;
sol:=min1*max1;
for i:=2 to min do if ok[i]=0 then
begin
aux:=(max1 div i)*(min1 div i);
if odd(f[i]) then dec(sol,aux)
else inc(sol,aux);
if f[i]=1 then
begin
aux1:=i;
aux1:=aux1*aux1;
aux:=aux1;
while aux<=min do
begin
ok[aux]:=1;
inc(aux,aux1);
end;
end;
end;
assign(output,'mins.out');rewrite(output);
writeln(sol);
close(output);
end.