Pagini recente » Cod sursa (job #240101) | Cod sursa (job #2289113) | Cod sursa (job #2222532) | Cod sursa (job #1412427) | Cod sursa (job #587082)
Cod sursa(job #587082)
var a:array[1..10000001] of byte;
i,n,nr,r:longint;
j,k:int64;
begin
assign(input,'ciur.in');reset(input);
assign(output,'ciur.out');rewrite(output);
readln(n);
nr:=1;
i:=1;r:=n mod 2;
n:=n div 2-1+r;
for i:=1 to trunc(sqrt(n*2+r)) div 2 do
if a[i]=0 then
begin
k:=(i shl 1+1);
j:=k*k;
while j<=(n*2+1) do
begin
a[j shr 1]:=1;
j:=j+2*k;
end;
end;
for i:=1 to n do
if a[i]=0 then inc(nr);
write(nr);
end.