题解 | #称砝码#

称砝码

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

while True:
    try:
        n = int(input())
        m = map(int,input().split())
        x = map(int,input().split())

        weight = {0}
        for mi,xi in zip(m,x):
            for i in range(xi):
                weight |= set([mi+s for s in weight])
        print(len(weight))
    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):  # xi 表示有几个
#                 weights |= set([s+mi for s in weights])  # n个玛法,一个个加入set里面
#         print(len(weights))
#     except:
#         break

全部评论

相关推荐

牛客146600443号:92的能看上这3k,5k在搞笑呢
点赞 评论 收藏
分享
11-04 14:10
东南大学 Java
_可乐多加冰_:去市公司包卖卡的
点赞 评论 收藏
分享
头像
10-16 09:58
已编辑
门头沟学院 Java
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务