No.302 Probability Problem with Dice (2)
タグ : / 解いたユーザー数 19
作問者 :
LayCurse
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もしくは右上の雲マークをクリックしてアカウントを作成してください。