leetcode骰子力码培训7-掷骰子模拟器为每卷生成一个从1到6的随机数。您向生成器引入了一个约束,使其不能连续滚动数字i超过rollMax[i](1索引)。
#!usr/bin/env python3
# -*- coding:utf-8 -*-
def dieSimulator(n, rollMax):
dp=[[0 for i in range(7)] for k in range(n+1)]
dp[0][-1]=1
for row in range(1,n+1):
for col in range(6):
for j in range(1,rollMax[col]+1):
if j<=row:
dp[row][col]+=dp[row-j][6]-dp[row-j][col]
dp[row][6]=sum(dp[row])
return dp[-1]%(10**9+7)
6- IP地址验证代码:
#!usr/bin/env python3
# -*- coding:utf-8 -*-
import re
number = int(input())
暂无评论