牛客华为机试HJ91
作者:互联网
1. 题目描述
2. Solution
1、思路分析
DFS
2、代码实现
import sys
if sys.platform != "linux":
file_in = open("input/HJ91.txt")
sys.stdin = file_in
def ways(x, y, m, n):
if x == (m - 1) and y == (n - 1):
global res
res += 1
return
if x + 1 < m:
ways(x + 1, y, m, n)
if y + 1 < n:
ways(x, y + 1, m, n)
def solve(m, n):
ways(0, 0, m, n)
for line in sys.stdin:
res = 0
m, n = map(int, line.strip().split())
solve(m + 1, n + 1)
print(res)
标签:ways,res,sys,牛客,file,HJ91,机试,line 来源: https://www.cnblogs.com/junstat/p/16177313.html