题解 | #HJ41 称砝码#

称砝码

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

n = int(input())

m_list = [i for i in map(int, input().strip().split())]
x_list = [i for i in map(int, input().strip().split())]

status = []
for i in range(n): # n种
    temp = []
    for j in range(x_list[i]+1): # 每种多少个
        temp.append(j * m_list[i])
    status.append(temp)

w_0 = set(status[0])
for i in range(1, n):
    w_i = set()
    for j in w_0:
        for k in status[i]:
            w_i.add(j+k)
    w_0 |= w_i
    i += 1

print(len(w_0))
全部评论

相关推荐

牛客101244697号:这个衣服和发型不去投偶像练习生?
点赞 评论 收藏
分享
评论
点赞
1
分享
牛客网
牛客企业服务