No.76 Practice with Expected Number of Rolls
タグ : / 解いたユーザー数 153
作問者 :
LayCurse
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もしくは右上の雲マークをクリックしてアカウントを作成してください。