Cod sursa(job #800866)
| Utilizator | Data | 22 octombrie 2012 20:29:01 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 100 |
| Compilator | fpc | Status | done |
| Runda | Arhiva educationala | Marime | 0.53 kb |
var f,g:text;
n,s,c,i:longint;
v:array[2..2000000] of byte;
b1,b2:array[1..1000000] of longint;
begin
assign(f,'ciur.in');
assign(g,'ciur.out');
settextbuf(f,b1);
settextbuf(g,b2);
reset(f);
rewrite(g);
readln(f,n);
s:=0;
fillchar(v,sizeof(v),1);
for i:=2 to n do
if v[i]=1 then
begin
c:=i+i;
inc(s);
while c<=n do
begin
v[c]:=2;
inc(c,i);
end;
end;
writeln(g,s);
close(f);
close(g);
end.
