题解 | 称砝码
称砝码
https://www.nowcoder.com/practice/f9a4c19050fc477e9e27eb75f3bfd49c
while True:
try:
nums = int(input())
weights = list(map(int, input().split()))
counts = list(map(int, input().split()))
s = {0}
for w, c in zip(weights, counts):
s = {x + k * w for x in s for k in range(c + 1)}
print(len(s))
except:
break
查看7道真题和解析