sum1 = int(input())
n = int(input())
m = []
for i in range(n):
a = int(input())
m.append(a)
visit = [0 for i in range(n)]
dd = []
def dfs(visit,i):
global m,sum1,dd
if sum(visit)==sum1:
k = []
for mm in range(len(m)):
if visit[mm]!=0:
k.append(visit[mm])
if k not in dd:
dd.append(k)
return
if i==len(m):
return
if sum(visit)
dfs(visit,i+1)
visit[i] = 0
dfs(visit,i+1)
cisu = 0
sum1 = sum(m)-sum1
m.sort()
dfs(visit,0)
for j in range(len(dd)):
for k in dd[j]:
print(k,end=' ')
print()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)