Cod sursa(job #26144)
Utilizator | Data | 5 martie 2007 11:36:30 | |
---|---|---|---|
Problema | Zero 2 | Scor | 20 |
Compilator | fpc | Status | done |
Runda | Arhiva de probleme | Marime | 0.73 kb |
var n,b,i,j,s,t,d,x,y:longint;
begin
assign(input,'zero2.in');
reset(input);
assign(output,'zero2.out');
rewrite(output);
for t:=1 to 10 do
begin
readln(n,b);
d:=0;
for i:=2 to b div 2 do
begin
if i*i>b then break;
if b mod i=0 then
begin
d:=b div i;
break;
end;
end;
if d=0 then d:=b;
x:=0;
for i:=2 to n do
begin
x:=x+i div d;
if i>=d*d then x:=x+1;
end;
if trunc(sqrt(b))=sqrt(b) then x:=x div 2;
writeln(x);
end;
close(output);
end.