题解 | 称砝码
称砝码
https://www.nowcoder.com/practice/f9a4c19050fc477e9e27eb75f3bfd49c
import sys n= int(input()) lm= list(map(int,input().split())) lx = list(map(int,input().split())) #一个个算重量 def quan(n,lm,lx): weigh={0} for i in range(n): weii = lm[i] mount = lx[i] currentweight = list(weigh) for j in currentweight: for k in range(1,mount+1): newweight = j+ weii * k weigh.add(newweight) return len(weigh) print(quan(n,lm,lx))