問題一覧 > 通常問題

No.301 Probability Problem with Dice (1)

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

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もしくは右上の雲マークをクリックしてアカウントを作成してください。