题解 | #放苹果#

放苹果

https://www.nowcoder.com/practice/bfd8234bb5e84be0b493656e390bdebf

def solution(m,n):
    dp = [[0 for i in range(n+1)] for j in range(m+1)]
    for i in range(m+1):
        dp[i][1] = 1
    for j in range(1,n+1):
        dp[0][j] = 1
        dp[1][j] = 1
    for i in range(2,m+1):
        for j in range(2,n+1):
            if i < j:
                dp[i][j] = dp[i][i]
            else:
                dp[i][j] = dp[i-j][j] + dp[i][j-1]

    return dp[m][n]

m,n = input().split()

print(solution(int(m),int(n)))

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务