MoYi123
2020 年 10 月 27 日
随便写了一个答案,应该是正解
def solution():
____a = [2, 3, 5, 7, 9]
____ret = []
____memo = set()
____def dp(index, acc):
________if (index, tuple(acc)) in memo:
____________return
________else:
____________memo.add((index, tuple(acc)))
________if index == 5:
____________return
________if sum(acc) == 13:
____________ret.append(tuple(acc))
________if sum(acc) >= 13:
____________return
________dp(index + 1, acc[:])
________dp(index, acc[:] + [a[index]])
____dp(0, [])
____return ret