题解 | #称砝码#

称砝码

http://www.nowcoder.com/practice/f9a4c19050fc477e9e27eb75f3bfd49c

集合

# 输入
n = int(input())
weight = list(map(int,input().split()))
weightNum = list(map(int,input().split()))
# 整合
arr = []
for i in range(n):
    for j in range(weightNum[i]):
        arr.append(weight[i])
# 所有组合情况
res = {0}
for i in arr:
    for j in list(res):
        # 集合去重
        res.add(i+j)
print(len(res))
        
全部评论

相关推荐

点赞 评论 收藏
分享
每晚夜里独自颤抖:要求太多的没必要理
点赞 评论 收藏
分享
评论
2
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务