题解 | #放苹果#
https://www.nowcoder.com/practice/bfd8234bb5e84be0b493656e390bdebf
m,n = map(int,input().split()) n_list = [0 for i in range(n)] result_list = [] #使用迭代的方法 def dfx(n_list): if sum(n_list) < m: tmp_list = [] for i in range(n): tmp = n_list.copy() tmp[i] += 1 tmp.sort() if tmp not in tmp_list: tmp_list.append(tmp) for i in tmp_list: dfx(i) # del tmp pass else: tmp = n_list.copy() tmp.sort() if tmp not in result_list: result_list.append(tmp) dfx(n_list) print(len(result_list))