题解 | #走方格的方案数#

走方格的方案数

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

from re import split
def path_count(x,y):
    if x == 0 or y == 0:
        return 1
    else:
        return path_count(x-1,y) + path_count(x,y-1)    

x, y = map(int, input().split())

print(path_count(x,y))

当 x==0 或者 y ==0时,路径只能往右走或者往下走只有一条路。而[x,y]的路径是只能从[x-1, y]和[x,y-1]的路径过来。

全部评论

相关推荐

彧未sr:查看图片
投递牧原集团等公司10个岗位
点赞 评论 收藏
分享
盖茨伯爵:一样兄弟,我从4月开始发到现在了,都三四百个了
无实习如何秋招上岸
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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