题解 | #放苹果#

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

全部评论

相关推荐

小浪_Coding:找硬件测试,也可兼顾软测欧, 简历还可以的 ,注意排版,项目写的有条理一点, 然后个人技能多加点, 润色好简历之后就开始沟通海投了,深圳,东莞这边做硬件相关的公司还不少, 医疗类,仪器类的都可以尝试
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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