from itertools import combinations
total = 5 + 10 # 总共店和花的数量
drink = 2 # 壶中原有2斗酒
# 穷举出所有可能情况
points = list(combinations(list(range(total)), drink))
res = 0 # 记录符合条件的可能情况
for point in points:
if point[-1] >= 5:
res += 1
print('一共有{}种符合条件的可能情况'.format(res))
全部评论: 0 条