Problem:
Score : 500 points

Problem Statement

Takahashi and Aoki will play a game. They will repeatedly play it until one of them have N wins in total.

When they play the game once, Takahashi wins with probability A %, Aoki wins with probability B %, and the game ends in a draw (that is, nobody wins) with probability C %.
Find the expected number of games that will be played, and print it as follows.

We can represent the expected value as P/Q with coprime integers P and Q.
Print the integer R between 0 and 10^9+6 (inclusive) such that R \times Q \equiv P\pmod {10^9+7}.
(Such an integer R always uniquely exists under the constraints of this problem.)

Constraints

1 \leq N \leq 100000

0 \leq A,B,C \leq 100

1 \leq A+B

A+B+C=100

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N A B C

Output

Print the expected number of games that will be played, in the manner specified in the statement.

Sample Input 1

1 25 25 50

Sample Output 1

2

Since N=1, they will repeat the game until one of them wins.
The expected number of games played is 2.

Sample Input 2

4 50 50 0

Sample Output 2

312500008

C may be 0.

Sample Input 3

1 100 0 0

Sample Output 3

1

B may also be 0.

Sample Input 4

100000 31 41 28

Sample Output 4

104136146

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<bits/stdc++.h>
#define ls(x) (x)<<1
#define rs(x) (x)<<1|1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define ll rt<<1
#define rr rt<<1|1
#define PI acos(-1)
#define MM int m=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define Case(i,ans) cout<<"Case "<<i<<": "<<ans<<endl;
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
//#define P pair<int,int>
using namespace std;
const int INF=LLONG_MAX;
const int maxn=1e6+5;
const int mo_num=1e9+7;
int n,m,a[maxn],b[maxn],ans;
int jc[maxn];
int Pow(int a,int b){//快速幂
    a%=mo_num;
    int ans = 1;
    while(b)
    {
        if(b&1)
            ans = (ans*a)%mo_num;
        a = (a*a)%mo_num;
        b/=2;
    }
    return ans%mo_num;
}
int ext_gcd(int a,int b,int &x,int &y){ if(b==0){x=1;y=0;return a;}int q=a/b, g=ext_gcd(b,a-q*b,x,y), z=x-q*y;x=y; y=z;return g; }
int inv(int a){ int x,y;ext_gcd(a,mo_num,x,y);return (x+mo_num)%mo_num; }
void init(int *x, int len){ x[0]=1;for(int i=1;i<len;i++)x[i]=(x[i-1]*i)%mo_num; }
int CC(int r,int n){ if(n<0 or n<r or r<0)return 0;return (jc[n]*inv(jc[r])%mo_num)*inv(jc[n-r])%mo_num; }
int A,B,C;
int did(int aa,int bb,int x)
{
    return mod(mod(Pow(aa,n)*Pow(bb,x-n))*Pow(inv(aa+bb),x));
}
int qw(int x)
{
    return mod(mod(CC(n-1,x-1)*(did(A,B,x)+did(B,A,x)))*mod((int)100*inv((int)100-C)));
}
int32_t main()
{
    IOS
    cin>>n>>A>>B>>C;
    init(jc,2*n+10);//这个是初始化阶乘数组的上限
    fu(i,n,2*n-1)
    {
        out(mod(i*qw(i)))
        ans=mod(ans+mod(i*qw(i)));
    }
    cout<<ans;
    return 0;
}