题解 | #称砝码#

称砝码

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

while True:
    try:
        n=int(input())
        weights=list(map(int,input().split()))
        nums=list(map(int,input().split()))
        
        res={0}
        for i,w in enumerate(weights):
            for j in range(nums[i]): # 每个砝码循环添加其数量次 
                for r in list(res): 
                    res.add(r + w)
        print(len(res))
    except:
        break

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-10 12:05
点赞 评论 收藏
分享
下个早班:秒挂就是不缺人
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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