Cod sursa(job #579313)

Utilizator Ghdel_RaduGhidel Ghdel_Radu Data 12 aprilie 2011 01:50:43
Problema Mins Scor 50
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.75 kb
const cmax=1000000;
var d:array[1..cmax]of qword;
    f,ok:array[1..cmax]of byte;
    x,y,max,min,i,j:longword;
    sol,aux: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:=0;
for i:=2 to min do if ok[i]=0 then
 begin
 if odd(f[i]) then inc(sol,(max div i)*(min div i))
  else dec(sol,(max div i)*(min div i));
 aux:=i*i;
 while aux<=min do
  begin
  ok[aux]:=1;
  inc(aux,i*i);
  end;
 end;
sol:=min*max-sol;
assign(output,'mins.out');rewrite(output);
writeln(sol);
close(output);
end.