题解 | #称砝码#

称砝码

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

while True:
    try:
        n = int(input())
        m = map(int,input().split())
        x = map(int,input().split())
        
        weights = {0}
        for xi,mi in zip(x,m):
            for i in range(xi):
                weights |=set([mi+s for s in weights])
        print(len(weights))
    except:
        break 
# while 1:
#     try:
#         n = int(input())
#         m = map(int, input().split())
#         x = map(int, input().split())
        
        # weights = {0}
        # for xi, mi in zip(x, m):
        #     for i in range(xi):
    #             weights |= set([s+mi for s in weights])
    #     print(len(weights))
    # except:
    #     break

全部评论

相关推荐

点赞 评论 收藏
分享
有工作后先养猫:太好了,是超时空战警,我们有救了😋
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务