题解 | #放苹果#

放苹果

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))

#放苹果#
全部评论

相关推荐

07-03 16:02
门头沟学院 Java
点赞 评论 收藏
分享
程序员小白条:你是沟通了900个,不是投了900份简历,你能投900份,意味着对面都要回复你900次,你早就找到实习了,没亮点就是这样的,别局限地区,时间投的也要早,现在都要7月了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务