import sys
import itertools
for line in sys.stdin:#获取输入
a = line.split()
ele = int (a[0])
del (a[0])
a = list (map (int, a))
flag=0
sumA=0
for i in range(0,len(a)):
sumA+=a[i]
if sumA<ele:
print ('-1')
else:
for i in range(1,len(a)+1):
for select in itertools.combinations(a, i):
sum = 0
for j in range(0,len(select)):
sum += select[j]
if sum == ele:
flag = 1
print(i)
break
if flag==1:
break
if flag == 1:
break
if flag==0:
print ('-1')
浦发银行算法接力赛总结/python语言/算法+建模/用户行为预测-07算法:曹冲称象
最新推荐文章于 2022-09-30 20:43:33 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)