問題一覧 > 通常問題

No.1033 Random Number Dice

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 小数誤差許容問題 絶対誤差または相対誤差が $10^{-5}$ 以下。ただし、ジャッジ側の都合で500桁未満にしてください
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 457
作問者 : Rute / テスター : nmnmnmnmnmnmnm
お気に入りにしたユーザー ProblemId : 4232 / 自分の提出
問題文最終更新日: 2020-04-21 20:43:20
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 245 (順位表) の他の問題:

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