def simplex_number(d, n):
# 动态规划表
dp = [[0] * (n + 1) for _ in range(d + 1)]
# 初始化一维简单形数
for i in range(1, n + 1):
dp[1][i] = i
# 动态递推
for dim in range(2, d + 1):
for num in range(1, n + 1):
dp[dim][num] = dp[dim][num - 1] + dp[dim - 1][num]
return dp[d][n]
# 示例:计算五维的第 4 项
result = simplex_number(5, 4)
print(f"9D 第 9 项:{result}")
ZGVmIHNpbXBsZXhfbnVtYmVyKGQsIG4pOgogICAgIyDliqjmgIHop4TliJLooagKICAgIGRwID0gW1swXSAqIChuICsgMSkgZm9yIF8gaW4gcmFuZ2UoZCArIDEpXQogICAgCiAgICAjIOWIneWni+WMluS4gOe7tOeugOWNleW9ouaVsAogICAgZm9yIGkgaW4gcmFuZ2UoMSwgbiArIDEpOgogICAgICAgIGRwWzFdW2ldID0gaQogICAgCiAgICAjIOWKqOaAgemAkuaOqAogICAgZm9yIGRpbSBpbiByYW5nZSgyLCBkICsgMSk6CiAgICAgICAgZm9yIG51bSBpbiByYW5nZSgxLCBuICsgMSk6CiAgICAgICAgICAgIGRwW2RpbV1bbnVtXSA9IGRwW2RpbV1bbnVtIC0gMV0gKyBkcFtkaW0gLSAxXVtudW1dCiAgICAKICAgIHJldHVybiBkcFtkXVtuXQoKIyDnpLrkvovvvJrorqHnrpfkupTnu7TnmoTnrKwgNCDpobkKcmVzdWx0ID0gc2ltcGxleF9udW1iZXIoNSwgNCkKcHJpbnQoZiI5RCDnrKwgOSDpobnvvJp7cmVzdWx0fSIpCg==