Pagini recente » Cod sursa (job #1216897) | Cod sursa (job #193821) | Cod sursa (job #907906) | Cod sursa (job #1206892) | Cod sursa (job #304834)
Cod sursa(job #304834)
program pascal;
var f,g:text; t:array[1..100000] of integer; x,p:array[1..1000] of longint;
max,i,k,j,n,aux:longint; c:int64;
procedure citire;
begin
assign(f,'economie.in'); reset(f);
assign(g,'economie.out'); rewrite(g);
readln(f,n);
max:=0;
for i:=1 to n do
begin
readln(f,x[i]);
if x[i]>max then max:=x[i];
end;
for i:=1 to 100000 do t[i]:=1;
close(f);
end;
procedure sort(s,d:longint);
var a,b,aux,ia:longint;
begin
a:=s; b:=d;
repeat
while x[a]<x[b] do b:=b-1;
aux:=x[a]; x[a]:=x[b]; x[b]:=aux; ia:=1; a:=a+1;
if a<b then
begin
while x[a]<x[b] do a:=a+1;
if a<>b then
begin
aux:=x[a]; x[a]:=x[b]; x[b]:=aux; ia:=0; b:=b-1;
end;
end;
until b<=a;
if a-ia>s then sort(s,a-ia);
if a-ia+1<d then sort(a-ia+1,d);
end;
procedure sorte;
begin
k:=0;
for j:=1 to n do
if t[x[j]]=1 then
begin
k:=k+1; p[k]:=x[j];
for i:=1 to max do
if (i mod p[k]=0) then t[i]:=0
else
begin
c:=i+x[j];
if (t[i]=0) then t[c]:=0;
end;
end;
end;
procedure afisare;
begin
writeln(g,k);
for i:=1 to k do writeln(g,p[i]);
close(g);
end;
begin
citire;
sort(1,n);
sorte;
afisare;
end.