题解 | #称砝码#

称砝码

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

import sys

while 1:
    try:
        n = int(input())    # 砝码的种数
        weight = list(map(int,input().split()))  # 砝码的重量
        number = list(map(int,input().split()))  # 每种砝码对应的数量 
    except:
        break
    else:
        amount = []
        c = {0,}
        for i in range(n):
            for j in range(number[i]):
                amount.append(weight[i])
        for i in amount:
            for j in list(c):   #循环时set转换回list
                c.add(j+i)
        #print(c)
        print(len(c))

全部评论

相关推荐

水色铃音:可以去找射频相关的岗位,比如圣邦微?或者像做产品的,比如xiaomi,oppovivo之类的,都需要天线调试的工程师
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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