1 import sys 2 m,n=list(map(int,sys.stdin.readline().strip().split())) 3 #def apple(m,n): 4 #return dp, dp[m][n] 5 if m<n: 6 m,n=m,m 7 dp=[[] for i in range(m+1)] 8 for i in range(n+1): 9 dp[1].append(1) 10 dp[0].append(1) 11 for i in range(2,m+1): 12 dp[i].append(1) 13 dp[i].append(1) 14 for i in range(2,m+1): 15 for j in range(2,n+1): 16 #print(i,j,dp) 17 if i<j: 18 dp[i].append(dp[i][i]) 19 else: 20 #print(i,j,dp[i][j-1]+dp[i-j][j]) 21 dp[i].append(dp[i][j-1]+dp[i-j][j]) 22 out=dp[m][n] 23 print(out)
标签:出界,递归,sys,dp,append,HJ61 From: https://www.cnblogs.com/tanyuanqing/p/17219988.html