問題一覧 > 通常問題

No.76 Practice with Expected Number of Rolls

レベル : / AI推定難易度 : 1325 / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 小数誤差許容問題 絶対誤差または相対誤差が $10^{-5}$ 以下。ただし、ジャッジ側の都合で500桁未満にしてください
タグ : (AC するまで非表示) / 解いたユーザー数 153
作問者 : LayCurse
お気に入りにしたユーザー ProblemId : 154 / 自分の提出
問題文最終更新日: 2026-06-25 12:34:54
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 56 (順位表) の他の問題:

Problem Statement

Die X has \(6\) faces, and the integers from \(1\) to \(6\) are written on the faces.
You keep rolling die X until the sum of the rolled values becomes at least \(N\).
Write a program that finds the expected number of rolls.
Assume that the results of the rolls are independent.
(The faces of the die are not necessarily equally likely to come up.)

Input

\(T\)
\(N_1\)
\(N_2\)
\(\vdots\)
\(N_T\)

\(1 \leq T \leq 50\): the number of test cases
\(1 \leq N_k \leq 10^6\): the value of $N$ in the $k$-th test case
Die X refers to the same die throughout the sample tests and the judge tests.

Output

On the \(k\)-th line, output the answer for the \(k\)-th test case.
Your answer is considered correct if the relative error is at most \(10^{-5}\).

Sample

Sample 1
Input
10
1
2
3
4
5
6
20
50
100
1000
Output
1.0000000000000000
1.0833333333333333
1.2569444444444444
1.5353009259259260
1.6915991512345676
2.0513639724794235
5.7894594000345325
13.789629635263326
27.122962962962941
267.12296296296188

This sample output is correct to about \(15\) digits, but note that a relative error of up to \(10^{-5}\) is actually allowed.

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