Fortune From Folly
Time limit1sMemory limit1024 MB
Given n, k, and success probability p, find the expected number of independent Bernoulli trials until the last n trials contain k successes.
- Level
Medium6 of 10
- Topics
- Probability, Dynamic programming, Math, Implementation
- Solved
- No attempts yet
Problem
Your friend Ómar's favourite video game is Striker-Count. But he has now grown tired of actually playing the game and is more interested in the lootboxes found in the game. Inside each lootbox there is an item of some level of rarity. Ómar is only interested in acquiring the rarest items in the game. When he starts the game, he chooses two numbers and , such that . He then opens lootboxes in the game until of the last lootboxes included an item of the highest rarity.
This activity amuses Ómar, but does not interest you in the slightest. You are more interested in the numbers: you know that each lootbox Ómar opens has probability of containing an item of highest rarity, independently for each lootbox. You want to find the expected number of lootboxes Ómar will open before concluding his process.
Input
The only line of the input contains the two integers and (), and the real number ( and has at most four decimals after the decimal point), with meanings as described above.
Output
Output the expected number of lootboxes Ómar must open, with a relative error of at most . It is guaranteed that the input is such that this expected number does not exceed .