Pagini recente » 11_sau_12_cercetasi | Cod sursa (job #1389572) | Cod sursa (job #1262742) | Cod sursa (job #2702717) | Cod sursa (job #154009)
Cod sursa(job #154009)
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);
ciur[1]:=0;
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;}
write(g,k);
close(f);
close(g);
end.