题解 | #称砝码#

称砝码

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))
        
全部评论

相关推荐

爱读书的放鸽子能手很...:刷个两端实习,冲春招,流水线什么时候不能去
我的秋招日记
点赞 评论 收藏
分享
09-25 23:37
已编辑
桂林电子科技大学 Java
点赞 评论 收藏
分享
评论
2
1
分享

创作者周榜

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