Cod sursa(job #1198866)
| Utilizator | Data | 17 iunie 2014 15:23:50 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 0 |
| Compilator | fpc | Status | done |
| Runda | Arhiva educationala | Marime | 0.75 kb |
var b:array[2..2000001] of boolean;
i,j: longint;
t: text;
s,n: longint;
begin
assign(t,'ciur.in');
reset(t);
readln(t,n);
close(t);
j:=1;s:=0;
while (sqr(j)<=n) do begin
inc(j);
if not(b[j]) then begin
i:=sqr(j);
while (i<n) do begin
b[i]:=true;
i:=i+j;
end;
end;
while (j<n) do begin
inc(j);
if not(b[j]) then inc(s);
end;
if not(b[j]) then inc(s);
end;
assign(t,'ciur.out');
rewrite(t);
writeln(t,s);
close(t);
end.
