题库练习 New Year and Arbitrary Arrangement
← 上一题 下一题 →

A11548 | New Year and Arbitrary Arrangement

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

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 ![](/uploads/luogu/CF908D/250bff4a0d2d6149565f6e795de0dbd59e6a92a3_0f6a247bb268.png). Print the value of ![](/uploads/acgo/image/15be87d23f677cc5_aa9c9997c4a0.jpeg).

输入格式

The first line will contain three integers integer $k,p_{a},p_{b}$ ( $1<=k<=1000$ , $1<=p_{a},p_{b}<=1000000$ ).

输出格式

Print a single integer, the answer to the problem.

输入输出样例

输入 #1
1 1 1
输出 #1
2
输入 #2
3 1 4
输出 #2
370000006
C++ 编辑器
输入
输出