No.1033 Random Number Dice
タグ : / 解いたユーザー数 457
作問者 :
Rute
/ テスター :
nmnmnmnmnmnmnm
Problem Statement
In general, a random number die is
a die on which each digit from 0 to 9 appears exactly 2 times.
Here, consider a die on which each integer from $0$ to $N$ appears exactly $K$ times.
(Each integer is assumed to come up with equal probability.)
Find the expected value of the number rolled on this die.
Input
$N$ $K$
The input consists of integers.
$1≦N≦10^5$
$1≦K≦10^5$
Output
Output the expected value of the number rolled on the die.
An error of at most $10^{-5}$ is allowed.
Sample
Sample 1
Input
2 2
Output
1.0
When $N=2$, $K=2$, the expected value of the number rolled is
$\frac{1}{6}×0+\frac{1}{6}×0+\frac{1}{6}×1+\frac{1}{6}×1+\frac{1}{6}×2+\frac{1}{6}×2= 1.0$
.
Sample 2
Input
4 3
Output
2.0
The expected value is $\frac{1}{15}×0+\frac{1}{15}×0+\frac{1}{15}×0+\frac{1}{15}×1+\frac{1}{15}×1+\frac{1}{15}×1 + \frac{1}{15}×2+\frac{1}{15}×2+\frac{1}{15}×2+\frac{1}{15}×3+\frac{1}{15}×3+\frac{1}{15}×3 + \frac{1}{15}×4+\frac{1}{15}×4+\frac{1}{15}×4= 2.0$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。