- 新年趣事之打牌
- 2013-10-16 17:20:50 @
var
n,m,i,j,k,num:longint;
f:array[0..100000]of longint;
w,a:array[1..100]of longint;
begin
readln(m); readln(n); f[0]:=1;
for i:=1 to n do readln(w[i]);
for i:=1 to n do
for j:=m downto w[i] do
f[j]:=f[j]+f[j-w[i]];
if f[m]=0 then writeln(0) else
if f[m]>1 then writeln(-1) else
begin
while m<>0 do
begin
i:=1;
while (f[m-w[i]])<>1 do inc(i);
a[i]:=1; m:=m-w[i];
end;
for i:=1 to n do if a[i]=0 then write(i,' ');
writeln;
end;
end.
0 条评论
目前还没有评论...