题解 | #称砝码#
称砝码
https://www.nowcoder.com/practice/f9a4c19050fc477e9e27eb75f3bfd49c
kind = int(input()) ms = list(map(int, input().split())) xs = list(map(int, input().split())) dp = [{0} for _ in range(kind + 1)] # dp[i]表示第i种及其之前的重量和 for i in range(1, kind + 1): for j in range(xs[i - 1] + 1): for val in dp[i - 1]: val = val + j * ms[i - 1] dp[i].add(val) print(len(dp[kind]))