#d11301. 序列中ab的个数
序列中ab的个数
Expected Number of "ab" Subsequences
Problem Description
You are given three integers . Initially there is an empty sequence. Each second, one of the following happens:
- with probability , append the character
ato the end; - with probability , append the character
bto the end.
The process stops as soon as the sequence contains at least occurrences of the subsequence ab. Find the expected total number of ab subsequences at the end, and output the answer modulo as an integer.
Input Format
One line containing three integers .
Output Format
One integer: the answer.
Sample Input 1
3 1 4
Sample Output 1
370000006
Sample Input 2
1 1 1
Sample Output 2
2
Constraints
For all data, and .