投掷一个筛子 import matplotlib.pyplot as pltfrom random import randintimport numpy as npclass Die:"""模拟投掷筛子"""def __init__(self,num_sides=6):self.num_sides=num_sidesdef roll(self):return randint(1,self.n
题目链接 题解: 设 d p [ i ] dp[i] dp[i] 表示当前分数为 i i i 要达到目标的期望,则: d p [ i ] = ∑ k = 3 k 1 + k 2 + k 3 ( p [ k ] ⋅ d p [ i + k ] ) + p [ 0 ] ⋅ d p [ 0 ] + 1 dp[i]=\sum_{k=3}^{k1+k2+k3} (p[k] \cdot dp[i