题目: |
var
a:array[1..20] of longint;
f:Array[0..20000]of boolean;
i,n:longint;
procedure dfs(t,sum:longint);
begin
if t>n then
begin
f[sum]:=true;
exit;
end;
dfs(t+1,sum);
dfs(t+1,sum+a[t]);
end;
begin
readln(n);
for i:=1 to n do
read(a[i]);
dfs(1 ,0);
for i:=1 to 20000 do
if not f[i] then break;
writeln(i);
end.
输入
9
1 2 4 8 16 32 64 128 256 输出:512
|