题解 | #称砝码#

称砝码

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

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-15 17:46
暑期就挂了,秋招还有机会吗
大聪明777:研发提前批,14号刚开的,官网上面的配图上有写。提前批没过的话,秋招还可以投,不过前面的笔试/面试记录会被保留,供秋招参考
26届校招投递进展
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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