Cod sursa(job #149895)

Utilizator netedu_andreiFII Andrei Netedu netedu_andrei Data 6 martie 2008 11:19:02
Problema Ciurul lui Eratosthenes Scor 0
Compilator fpc Status done
Runda Arhiva educationala Marime 0.59 kb
program ciur;
var f,g:text;
    i,j,n,k,s:longint;
    a:array[1..2000]of byte;
begin
assign(f,'ciur.in');reset(f);
assign(g,'ciur.out');rewrite(g);
readln(f,n);
s:=0;
for i:=2 to n do
    if a[i]=0 then begin
                   k:=i;
                   s:=s+1;
                   for j:=2 to n div k do a[j*k]:=1;

                   end;
writeln(g,s);
j:=0;
for i:=n downto 2 do
    if a[i]=0 then begin
                   j:=j+1;
                   if j=1000 then break;
                   end;
for i:=a[i] to n do
    if a[i]=0 then write(g,i,' ');
close(f);
close(g);
end.