Pagini recente » Cod sursa (job #1943353) | Cod sursa (job #2019857) | Cod sursa (job #1780160) | Cod sursa (job #2150089) | Cod sursa (job #121936)
Cod sursa(job #121936)
var f,g:text;
i,n:integer;
j:longint;
a:array[1..1000] of longint;
s:array[0..3000] of -1..1;
sw:boolean;
function poz(li,ls:integer):integer;
var i,j,modi,modj,m:longint;
man:longint;
begin
i:=li;j:=ls;
modi:=0;modj:=-1;
while i<j do
begin
if a[i]>a[j] then
begin
man:=a[i];a[i]:=a[j];a[j]:=man;
m:=modi;
modi:=-modj;
modj:=-m;
end;
i:=i+modi;
j:=j+modj;
end;
poz:=i;
end;
procedure quick(li,ls:integer);
begin
if li<ls then
begin
j:=poz(li,ls);
quick(li,j-1);
quick(j+1,ls);
end;
end;
begin
assign(f,'economie.in');reset(f);
assign(g,'economie.out');rewrite(g);
readln(f,n);
for i:=1 to n do
read(f,a[i]);
{sw:=false;
repeat
sw:=true;
for i:=1 to n-1 do
if a[i]>a[i+1] then
begin
sw:=false;
j:=a[i];a[i]:=a[i+1];a[i+1]:=j;
end;
until sw;}
quick(1,n);
s[0]:=1;
for i:=1 to n do
begin
if s[a[i]]=0 then
s[a[i]]:=-1;
for j:=0 to a[n] do
if ((s[j]=1) or (s[j]=-1)) and (s[j+a[i]]<>-1) then s[j+a[i]]:=1;
end;
j:=0;
for i:=1 to n do
if s[a[i]]=-1 then
j:=j+1;
writeln(g,j);
for i:=1 to n do
if s[a[i]]=-1 then
write(g,a[i],' ');
close(g);
end.