結果

問題 No.1682 Unfair Game
ユーザー Navier_Boltzmann
提出日時 2021-09-17 23:04:32
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 843 bytes
コンパイル時間 79 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-06-29 21:51:53
合計ジャッジ時間 1,536 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 13 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 3  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
    
mod = 10**9 + 7
N = int(input())
p = list(map(int,input().split()))
front = 0
back = 0
eq = 0
for tp in p:
    if tp>50:
        front += 1
    elif tp < 50:
        back += 1
    else:
        eq += 1
        
cnt = 0
ans = 0
while 2*cnt+1 <= front:
    ans += cmb(front,2*cnt+1,mod)
    cnt += 1
    ans %= mod
    
ans *= pow(2,back+eq,mod)
print(ans%mod)
0