题解 | #放苹果#
放苹果
https://www.nowcoder.com/practice/bfd8234bb5e84be0b493656e390bdebf
#当盘子数为n时,采用一个列表,从0个苹果开始,递增列举苹果的摆放方式 m, n = input().split() m = int(m) n = int(n) list_apple_1 = [[0] * n] for i in range(m): list_apple_0 = [] for item in list_apple_1: for j in range(n): item_new = item.copy() item_new[j] = item[j] + 1 item_new.sort() if item_new not in list_apple_0: list_apple_0.append(item_new) list_apple_1 = list_apple_0 print(len(list_apple_0))#放苹果#