Contest Duration: - (local time) (120 minutes)

Submission #5735307

Source Code Expand

Copy
```# 約分無視できる！！
# A+B/100で勝負がつくので、最後に100/A+Bをかける
MOD = 10**9 + 7

def inv_mod(a):
return pow(a,MOD-2,MOD)

U = 10**5
UU = 2*U
N,A,B,C = map(int,input().split())
pow_A = [1] * (U+1)
pow_B = [1] * (U+1)
pow_AB = [1] * (U+1)
for n in range(1,U+1):
pow_A[n] = (pow_A[n-1]*A)%MOD
pow_B[n] = (pow_B[n-1]*B)%MOD
pow_AB[n] = (pow_AB[n-1]*(A+B))%MOD

fact = [1] * (UU+1)
for n in range(1,UU+1):
fact[n] = (n*fact[n-1])%MOD
fact_inv = [1] * (UU+1)
fact_inv[UU] = inv_mod(fact[UU])
for n in range(UU,0,-1):
fact_inv[n-1] = (n*fact_inv[n])%MOD

def comb(n,k):
x = fact[n]
x *= fact_inv[k]
x %= MOD
x *= fact_inv[n-k]
x %= MOD
return x

num = 0 # 分母を(A+B)^Nと見て分子
for k in range(N):
# N-1勝k敗になった後1勝
x = comb(N-1+k,k)
x *= pow_B[k]
x %= MOD
x *= pow_A[N]
x %= MOD
x *= pow_AB[N-k]
x %= MOD
x *= (N+k)
x %= MOD
num += x

for k in range(N):
# N-1勝k敗になった後1勝
x = comb(N-1+k,k)
x *= pow_A[k]
x %= MOD
x *= pow_B[N]
x %= MOD
x *= pow_AB[N-k]
x %= MOD
x *= (N+k)
x %= MOD
num += x

# 分母は(A+B)^N
den = pow(A+B,N+N,MOD)

# 最後に引き分けの補正

```

#### Submission Info

Submission Time 2019-06-01 22:31:03+0900 C - Best-of-(2n-1) maspy Python (3.4.3) 500 1403 Byte AC 596 ms 30708 KB

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
 AC × 4
 AC × 13
Set Name Test Cases
Sample example0.txt, example1.txt, example2.txt, example3.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, example0.txt, example1.txt, example2.txt, example3.txt
Case Name Status Exec Time Memory
000.txt AC 550 ms 30708 KB
001.txt AC 577 ms 30708 KB
002.txt AC 560 ms 30708 KB
003.txt AC 566 ms 30708 KB
004.txt AC 596 ms 30708 KB
005.txt AC 549 ms 30708 KB
006.txt AC 569 ms 30708 KB
007.txt AC 547 ms 27508 KB
008.txt AC 592 ms 30708 KB
example0.txt AC 234 ms 30708 KB
example1.txt AC 232 ms 30708 KB
example2.txt AC 222 ms 27636 KB
example3.txt AC 568 ms 30708 KB