题解 | #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))