406466: GYM102416 D Calculated risk
Description
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.
InputInput is two numbers $$$3\leq k\leq 20$$$ and $$$1\leq n \leq 5$$$.
OutputPrint 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}$$$.
ExampleInput6 2Output
42.00