No.301 Probability Problem with Dice (1)
タグ : / 解いたユーザー数 49
作問者 :
LayCurse
Problem Statement
There is an ordinary die that shows each integer from $1$ to $6$ with equal probability.
You keep rolling this die until the sum of the rolls is exactly $N$.
However, whenever the sum of the rolls exceeds $N$ along the way, the sum is reset to $0$ each time.
Write a program that finds the expected number of rolls.
Assume that the rolls of the die are independent.
Hint: Exactly the same problem is here → https://yukicoder.me/problems/129.
Input
Line $1$ contains the number of test cases $T$.
Each test case is given in the following format.
$N$
$1 \leq T \leq 10000 = 10^4$
$1 \leq N \leq 10^{18}$
Output
For each test case, output the expected number of rolls of the die on $1$ line.
Your answer is considered correct if the relative error is at most $10^{-12}$.
Sample
Sample 1
Input
4 1 2 3 7
Output
6 6 6 9.9431493245813
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。