問題一覧 > 通常問題

No.65 Practice of Expected Number of Times

レベル : / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 小数誤差許容問題 絶対誤差または相対誤差が $10^{-2}$ 以下。ただし、ジャッジ側の都合で500桁未満にしてください
タグ : (AC するまで非表示) / 解いたユーザー数 370
作問者 : nmnmnmnmnmnmnm
お気に入りにしたユーザー ProblemId : 84 / 自分の提出
問題文最終更新日: 2020-09-02 19:31:01
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 52 (順位表) の他の問題:

Problem Statement

You want to roll one die some number of times to make the sum of the rolled values at least \(K\).
Find the expected number of times the die is rolled.

For this die, it is known that the formula for the expected number of rolls \(E(x)\) is as follows.
\(E(x)\) := the expected number of further rolls needed until the sum reaches \(K\), when the sum of the values so far is \(x\)
\( E(x)=E(x+1)*1/6+E(x+2)*1/6+E(x+3)*1/6+E(x+4)*1/6+E(x+5)*1/6+E(x+6)*1/6+1\)

Input

K

K is a positive integer. \(1\le K \le 20 \).

Output

Output the expected value on one line. An absolute or relative error of up to 0.01 is allowed.
Do not forget the newline at the end.

Sample

Sample 1
Input
1
Output
1

When x>=1, E(x)=0, and when x=0, E(0)=1.
Rolling the die once can be expected to make the sum of the values at least 1.

Sample 2
Input
2
Output
1.16667

Sample 3
Input
3
Output
1.36111

Sample 4
Input
7
Output
2.52163

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。