Pagini recente » Cod sursa (job #470975) | Cod sursa (job #1541270) | Cod sursa (job #1913562) | Cod sursa (job #317474) | Cod sursa (job #151965)
Cod sursa(job #151965)
type vector=array[1..2000000]of 0..1;
var f,g:text;
ciur:vector;
s:array[1..1000]of longint;
i,j,k,n:longint;
begin
assign(f,'ciur.in');
assign(g,'ciur.out');
reset(f);
rewrite(g);
read(f,n);
for i:=2 to n do
ciur[i]:=1;
for i:=2 to n do
if ciur[i]=1 then
for j:=2 to n div i do
ciur[i*j]:=0;
k:=0;
for i:=2 to n do
if ciur[i]=1 then
begin
inc(k);
end;
if k>1000 then
begin
writeln(g,k);
j:=0;
i:=n;
repeat
if ciur[i]=1 then
begin
j:=j+1;
s[j]:=i;
end;
i:=i-1;
until j=1000;
for j:=1000 downto 1 do
write(g,s[j]);
end else
begin
writeln(g,k);
for i:=2 to n do
if ciur[i]=1 then write(g,i,' ');
end;
close(f);
close(g);
end.