Pagini recente » Cod sursa (job #3222434) | Cod sursa (job #701657) | Cod sursa (job #619120) | Cod sursa (job #2779410) | Cod sursa (job #579306)
Cod sursa(job #579306)
const cmax=1000000;
var d:array[1..cmax]of qword;
f,ok:array[1..cmax]of byte;
x,y,max,min,i,j:qword;
sol: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;
sol:=max*min;
for i:=2 to min do if ok[i]=0 then
begin
if odd(f[i]) then dec(sol,(max div i)*(min div i))
else inc(sol,(max div i)*(min div i));
j:=i*i;
while j<=min do
begin
ok[j]:=1;
j:=j*i;
end;
end;
assign(output,'mins.out');rewrite(output);
writeln(sol);
close(output);
end.