Cod sursa(job #587073)
| Utilizator | Data | 3 mai 2011 20:26:34 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 10 |
| Compilator | fpc | Status | done |
| Runda | Arhiva educationala | Marime | 0.4 kb |
var a:array[1..10000001] of byte;
j,i,n,nr,r:longint;
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 n do
if a[i shl 1+1]=0 then
begin
k:=(i shl 1+1);
for j:=3 to (n*2+1) div k do
a[(j*k) shr 1]:=1;
end;
for i:=1 to n do if a[i]=0 then inc(nr);
write(nr);
end.
