F - Black Jack 解説 by en_translator
First, let us find the probability \(p[i]\) that \(y=i\). This can be found with dynamic programming (DP).
Specifically, start with \(\mathrm{p}[0]=1\), and for each \(i=0,1,\ldots,l-1\), add \(\frac{\mathrm{p}[i]}{D}\) to \(\mathrm{p}[i+1], \ldots,\mathrm{p}[i+D]\). This can be done fast with cumulative sum trick. Or, one can regard it as receiving DP to process it using cumulative sum.
Then, let us find the probability of winning \(q[i]\) when stopping at \(x=i\). This can be found as cumulative sums of \(p[i]\), which was found above.
Finally, find the probability of winning \(r[i]\) when \(x=i\). Corresponding to whether or not to roll the die, we have
\[r[i] = \max(q[i], \frac{1}{D}\sum_{j=i+1}^{i+D}r[j]),\]
so \(r\) can be found in descending order of \(i\). The resulting \(r[0]\) is the answer.
投稿日時:
最終更新: