問題一覧 > 通常問題

No.302 Probability Problem with Dice (2)

レベル : / AI推定難易度 : 1900 / 実行時間制限 : 1ケース 6.000秒 / メモリ制限 : 128 MB / 小数誤差許容問題 絶対誤差または相対誤差が $2 \times 10^{-5}$ 以下。ただし、ジャッジ側の都合で500桁未満にしてください
タグ : (AC するまで非表示) / 解いたユーザー数 19
作問者 : LayCurse
お気に入りにしたユーザー ProblemId : 190 / 自分の提出
問題文最終更新日: 2026-06-25 01:11:35
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.
Write a program that computes the probability that the sum of the rolled values is at least $L$ and at most $R$ when this die is rolled independently $N$ times.

Input

$N$
$L$ $R$

$1 \leq N \leq 10^{18}$
$0 \leq L \leq R \leq 10^{18}$

Output

Output the probability that is the answer on $1$ line.
Your output is considered correct if its difference from the prepared answer is at most $2 \times 10^{-5}$. The prepared answer is believed to have an absolute error of at most $10^{-5}$ from the true answer.
(In the initial dataset, the error between the prepared answer and the true answer is not this large, but this setting was chosen in anticipation of possible additional cases.)

Sample

Sample 1
Input
2
1 4
Output
0.166666666666667

When rolling $2$ dice, the sum is at least $1$ and at most $4$ for $6$ of the $36$ combinations of rolled values, namely $(1,1),(1,2),(1,3),(2,1),(2,2),(3,1)$, so the answer is $6/36$.

Sample 2
Input
10000
34888 35222
Output
0.648645471121652
Sample 3
Input
9876543210
0 1000000000000000000
Output
1

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