409208: GYM103456 K Marbles Pt. II
Description
Player 278 is upset about Player 101's treachery in their previous game of marbles and asks the Front Man for another chance to beat Player 101 in a marble game. The Front Man, upset about one of his guards ruining the sanctity of the game by colluding with Player 101, grants the request and lets player 278 pick the new game.
Player 101 starts with $$$n$$$ marbles. Due to player 278's expertise in the new game, for every integer $$$t$$$, if player 101 has $$$m$$$ marbles at the end of round $$$t$$$, then during round $$$t + 1$$$, for each of the $$$m$$$ marbles, player 278 has a probability of $$$p$$$ of taking it from player 101.
Given this, the Front Man wants to know the expected number of rounds it will take for player 278 to take all of player 101's $$$n$$$ marbles. This number can be expressed as some rational $$$\frac{p}{q}$$$. Output $$$pq^{-1} \pmod {10^9 + 7}$$$.
InputThe input is a single line containing two space-separated integers $$$n$$$ and $$$p$$$ ($$$1 \leq n \leq 500$$$ and $$$1 \leq p \leq 100$$$) where $$$n$$$ is the number of marbles that player 101 starts with and $$$p$$$ is the probability of taking a marble.
OutputThe expected number of rounds (modulo $$$10^{9} + 7$$$) it will take for player 278 to take all of player 101's $$$n$$$ marbles.
ExamplesInput2 100Output
1Input
1 50Output
2Input
5 33Output
737005287