题解 | #放苹果#

放苹果

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



m , n = map(int,input().split())

a = [[0]*(n+1) for _ in range(m+1)]

for j in range(1,n+1):
    a[1][j] = 1
    a[0][j] =1

for i in range(1,m+1):
    a[i][1] = 1

for i in range(2,m+1):
    for j in range(2,n+1):
        if i<j:
            #至少存在一个空盘
            a[i][j] = a[i][j-1]
        else:
            #至少存在一个空盘a[i][j-1]
            #没有空盘 a[i-j][j]
            a[i][j] = a[i][j-1]+a[i-j][j]

print(a[m][n])

全部评论

相关推荐

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