409208: GYM103456 K Marbles Pt. II

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

Description

K. Marbles Pt. IItime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

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}$$$.

Input

The 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.

Output

The expected number of rounds (modulo $$$10^{9} + 7$$$) it will take for player 278 to take all of player 101's $$$n$$$ marbles.

ExamplesInput
2 100
Output
1
Input
1 50
Output
2
Input
5 33
Output
737005287

加入题单

算法标签: