a*****2 发帖数: 96 | 1 dp[0][j] = 0, j = 0,1,...,R
dp[i][0] = 1, i = 1,...,W
for i in 1:W+1
for j in 1:R+1
probW = i/(i+j)
probR = j/(i+j)
probRandomAndEat = probW * dp[i-1][j] + probR*[i][j-1]
dp[i][j] = probW * dp[i-1][j] + probR* probRandomAndEat
return dp[W][R] |
|