十大配料圣代
Ten Topping Sundae
题目详情
在冰淇淋店,你会看到 10 种配料供你选择。你可以用这 10 种配料制作出多少种不同的冰淇淋组合?假设你必须选择至少 1 种配料。
At an ice cream parlor you are presented with 10 toppings to choose from. How many different combinations of ice cream can you create with those 10 toppings? Assume that you must choose at least 1 topping.
解析
这个问题的简单解决方案就是使用组合公式。我们知道我们可以制作带有 1 种配料、2 种配料、...、10 种配料的冰淇淋。因此,我们可以创建的冰淇淋变体总数()可以简单地表示为:
然而,解决这个问题的更优雅的方法是使用幂集。对于每种配料,你可以选择包含或不包含它。因此,你总共有 个冰淇淋变体选择(我们减去 1,因为我们不允许选择所有 10 种配料均为 False 的组合,即必须至少有 1 种配料)。
Original Explanation
The trivial solution to this problem would be to just use the combination formula. We know that we can either create an ice cream with 1 topping, 2 toppings, ..., 10 toppings. Therefore the total number of ice cream variants () that we could create can be expressed simply as:
However, a more elegant solution of this problem would be to use the power set. For each topping you have the choice to either include it or not include it. Therefore you have total choices of ice cream variants (we subtract 1 because we are not allowed to choose the combination in which all 10 toppings are False ie. there must be at least 1 topping).