P26565 [AtCoder] Best-of-(2n-1)
提高
题目描述

Problem Description

Takahashi and Aoki are playing a game. They will repeat the game until one of them wins a total of $N$ times.

When they play a game, the probability that Takahashi wins is $A$%, the probability that Aoki wins is $B$%, and the probability of a draw (neither wins) is $C$%. Calculate the expected number of games played and output it as specified below.

The expected value can be expressed as $P/Q$ using coprime integers $P$ and $Q$. Output the integer $R$ such that $R \times Q \equiv P \pmod{10^9+7}$ and $0 \leq R \leq 10^9+6$. (Under the constraints of this problem, such $R$ always uniquely exists.)

Input Format

The input is given from the standard input in the following format:

$N$ $A$ $B$ $C$

Output Format

Output the expected number of games played according to the method specified in the problem statement.

Sample Input and Output

Sample Input #1

1 25 25 50

Sample Output #1

2

Sample Input #2

4 50 50 0

Sample Output #2

312500008

Sample Input #3

1 100 0 0

Sample Output #3

1

Sample Input #4

100000 31 41 28

Sample Output #4

104136146

Notes/Hints

Constraints

  • $1 \leq N \leq 100000$
  • $0 \leq A, B, C \leq 100$
  • $1 \leq A + B$
  • $A + B + C = 100$
  • All inputs are integers

Sample Explanation 1

Since $N=1$, the game is repeated until one of them wins. The expected value is $2$.

Sample Explanation 2

$C=0$ can occur.

Sample Explanation 3

$B=0$ can also occur.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1 25 25 50
样例输出
2