题解 | #称砝码#

称砝码

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

n = int(input())
m = list(map(int,input().split()))
x = list(map(int,input().split()))

amount = []
weight = {0,}#最起码可以称个0重量,就是不放砝码

#打印所有的砝码重量
for i in range(n):
    for j in range(x[i]):
        amount.append(m[i])

#print(amount)
for i in amount:
    for j in list(weight):
        weight.add(i + j)
#print(weight)
print(len(weight))

全部评论

相关推荐

评论
点赞
收藏
分享
牛客网
牛客企业服务