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