Good Bye 2017
D
New Year and Arbitrary Arrangement
Codeforces
2200
原题
← CE →
翻译中…

You are given three integers $*k*$, $*p*_{*a*}$ and $*p*_{*b*}$.

翻译中…

You will construct a sequence with the following algorithm: Initially, start with the empty sequence. Each second, you do the following. With probability $*p*_{*a*} / (*p*_{*a*} + *p*_{*b*})$, add 'a' to the end of the sequence. Otherwise (with probability $*p*_{*b*} / (*p*_{*a*} + *p*_{*b*})$), add 'b' to the end of the sequence.

翻译中…

You stop once there are at least $*k*$ subsequences that form 'ab'. Determine the expected number of times 'ab' is a subsequence in the resulting sequence. It can be shown that this can be represented by $*P* / *Q*$, where $*P*$ and $*Q*$ are coprime integers, and image. Print the value of image.

翻译中…

Input

翻译中…

The first line will contain three integers integer $*k*, *p*_{*a*}, *p*_{*b*}$ ($1 ≤ *k* ≤ 1 000$, $1 ≤ *p*_{*a*}, *p*_{*b*} ≤ 1 000 000$).

翻译中…

Output

翻译中…

Print a single integer, the answer to the problem.

翻译中…

Note

翻译中…

The first sample, we will keep appending to our sequence until we get the subsequence 'ab' at least once. For instance, we get the sequence 'ab' with probability 1/4, 'bbab' with probability 1/16, and 'aab' with probability 1/8. Note, it's impossible for us to end with a sequence like 'aabab', since we would have stopped our algorithm once we had the prefix 'aab'.

翻译中…

The expected amount of times that 'ab' will occur across all valid sequences is 2.

翻译中…

For the second sample, the answer is equal to image.

翻译中…

样例

Input #1
1 1 1
Output #1
2
InputCopy OutputCopy
Input #2
3 1 4
Output #2
370000006
InputCopy OutputCopy
题目信息
题号
908D
所属比赛
时间限制
2 s
内存限制
256 MB
标签
动态规划
数学
概率论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。