← Back to Problems
Expected Maximum of Dice
Easy standard Probability & Statistics
Time limit: 1 s per test  ·  Memory: 256 MB

You roll n independent fair dice, each with faces numbered 1 to m. Let X be the largest value shown. Compute the expected value E[X].

Input

Two integers n and m.

Output

Output E[X] with absolute or relative error at most 1e-6.

Constraints

1 <= n <= 10^9

2 <= m <= 10^5

Scoring

This is a standard problem: a submission scores full points if it produces the correct output for every test case, and zero otherwise.

Numeric answers are accepted if they are within an absolute tolerance of 1e-06 or a relative tolerance of 1e-06 of the expected value.

Examples

input
1 6
output
3.500000000
input
2 6
output
4.472222222
Python 3.13 i Execution environment Isolated microVM · 1 vCPU · no internet access Time and memory limits are set per problem Available packages numpy 2.5.0scipy 1.18.0pandas 3.0.0scikit-learn 1.9.0statsmodels 0.15.0cvxpy 1.9.2