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: Accepted)

#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint extgcd(lint a, lint b, lint &x, lint &y) {
  lint g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
lint invMod(lint a, lint m) {
  lint x, y;
  if (extgcd(a, m, x, y) == 1) return (x + m) % m;return 0;
}
int a,b,c;
lint mo=1000000007;
lint ap[214514],bp[214514],sp[214514],ka[252521],rk[252521];
lint co(int a,int b){
	if(a<0 || b<0 || a<b) return 0;
	return (ka[a]*rk[b])%mo*rk[a-b]%mo;
}
int main()
{
	int n,a,b,c;cin>>n>>a>>b>>c;
	ka[0]=1;
	rep(i,252500) ka[i+1]=(ka[i]*(i+1))%mo;
	rep(i,252500) rk[i]=invMod(ka[i],mo);
	ap[0]=bp[0]=sp[0]=1;
	rep(i,214510) ap[i+1]=(ap[i]*a)%mo,bp[i+1]=(bp[i]*b)%mo,sp[i+1]=(sp[i]*(a+b))%mo;
	lint out=0;
	rep(i,n){
		//a*n,b*i
		out+=(((ap[n]*bp[i])%mo*invMod(sp[n+i],mo))%mo*co(n+i-1,i))%mo*(n+i);out%=mo;
		//a*i,b*n
		out+=(((ap[i]*bp[n])%mo*invMod(sp[n+i],mo))%mo*co(n+i-1,i))%mo*(n+i);out%=mo;
	}
	out*=invMod(a+b,mo);out%=mo;out*=100;out%=mo;
	cout<<out<<endl;
}