题解 | #称砝码#

称砝码

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

全部评论

相关推荐

10-02 19:29
已编辑
浙江科技大学 运营
点赞 评论 收藏
分享
10-13 16:58
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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