一眼过去就是递归,看完题解发现还是大佬们的方法快,给跪了 from functools import cache @cache def dfs(i, total): if i == n: ans.add(total) return for j in range(X[i]+1): v = j*M[i] total += v dfs(i+1, total) total -= v while True: try: n = int(input().strip())...