题解 | #称砝码#

称砝码

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

全部评论

相关推荐

03-21 08:46
已编辑
门头沟学院 C++
只写bug的程序媛:本科能找到好的,真不建议读研,提前占坑比较好,本科找不到好的,也不建议读研,因为两三年之后压力只会更大,唯一的解就是行业好起来
点赞 评论 收藏
分享
03-27 17:35
门头沟学院 C++
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务