思路是,对于每个数都有选或不选,则有2^10=1024种组合。只需求出每个组合的总分,添加到集合里面,因为集合会自动去重,最后打印集合的长度就可以了。
scores=[5,5,10,10,15,15,20,20,25,25]
possible_set=set()
for i in range(1024):
total=0
for j in range(10):
if (i>>j)&1:
total+=scores[j]
possible_set.add(total)
print(len(possible_set))