406466: GYM102416 D Calculated risk

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

D. Calculated risktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

We have a dice with $$$k$$$ sides that is rolled over and over again. You have to pay $$$£1$$$ for each time the dice is rolled. The prize is paid if at some you get a streak of $$$n$$$ consecutive ones (the dice shows 1). What is the mininum prize you should ask for in order to make profit from such game?

In other words what is the expected number of turns before streak of $$$n$$$ is hit.

For example let's say that the results of a regular $$$6$$$-sided dice are: $$$1,3,1,1,1$$$.

For $$$n=3$$$ you receive the prize after paying $$$£5$$$ for those $$$5$$$ turns.

Input

Input is two numbers $$$3\leq k\leq 20$$$ and $$$1\leq n \leq 5$$$.

Output

Print out the expected number of times you have to roll the dice to get a streak of $$$n$$$ ones. You can assume that the answer will be no bigger than $$$10^9$$$. We expect the accuracy of $$$10^{-4}$$$.

ExampleInput
6 2
Output
42.00

加入题单

上一题 下一题 算法标签: