把m个同样的足球放进n个同样的篮子里,允许有的篮子为空,问共有几种分法?
例如:3, 2, 1和2, 1, 3是同一种分法。
if __name__ == "__main__": nm = list(input().split(" ")) n = int(nm[1]) m = int(nm[0]) dp = [[0 for i in range(m+1)] for j in range(n+1)] dp[0][0] = 0 for i in range(1, m+1): dp[0][i] = 1 for i in range(1, n+1): for j in range(1, m+1): if i >= j: dp[i][j] = dp[i][j-1] + dp[i-j][j] else: dp[i][j] = dp[i][j-1] print(str(dp[n][m]))