結果

問題 No.995 タピオカオイシクナーレ
ユーザー nehan_der_thalnehan_der_thal
提出日時 2020-02-21 22:26:40
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 1,260 bytes
コンパイル時間 682 ms
コンパイル使用メモリ 86,952 KB
実行使用メモリ 76,772 KB
最終ジャッジ日時 2023-07-30 06:28:31
合計ジャッジ時間 3,836 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,324 KB
testcase_01 AC 68 ms
71,116 KB
testcase_02 AC 69 ms
71,460 KB
testcase_03 AC 69 ms
71,528 KB
testcase_04 AC 70 ms
71,120 KB
testcase_05 AC 70 ms
71,192 KB
testcase_06 AC 68 ms
71,456 KB
testcase_07 AC 69 ms
71,468 KB
testcase_08 AC 72 ms
71,532 KB
testcase_09 AC 71 ms
71,116 KB
testcase_10 AC 69 ms
71,212 KB
testcase_11 AC 71 ms
71,184 KB
testcase_12 AC 70 ms
71,472 KB
testcase_13 AC 70 ms
71,168 KB
testcase_14 AC 70 ms
71,220 KB
testcase_15 AC 68 ms
71,160 KB
testcase_16 AC 102 ms
76,772 KB
testcase_17 AC 94 ms
76,440 KB
testcase_18 AC 101 ms
76,504 KB
testcase_19 AC 102 ms
76,712 KB
testcase_20 AC 97 ms
76,592 KB
testcase_21 AC 96 ms
76,420 KB
testcase_22 AC 95 ms
76,528 KB
testcase_23 AC 97 ms
76,472 KB
testcase_24 AC 100 ms
76,628 KB
testcase_25 AC 97 ms
76,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
mod = pow(10, 9) + 7
sys.setrecursionlimit(pow(10, 8))

def power(x, y):
    if   y == 0: return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else: return power(x, (y-1)//2)**2 * x % mod
    
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def div(a, b):
    return mul(a, power(b, mod-2))
def div2(a, b):
    return mul(a, modinv(b))

def modinv(a):
    b, u, v = mod, 1, 0
    while b:
        t = a//b
        a, u = a-t*b, u-t*v
        a, b, u, v = b, a, v, u
    u %= mod
    return u

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NNN = (10)
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, NNN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N, M, K, p, q = map(int, input().split())
b1 =0
for _ in range(M):
    b1 += int(input())
b2 = 0
for _ in range(N-M):
    b2 += int(input())

#print(q-2*p)
#print((q-2*p)/ q)
pp = div2((q-2*p), q)
#print(pp)
ppp = power(pp, K)
#print(ppp)
print(mul(mul(1+power(pp, K), b1) + mul(1-power(pp, K), b2), inverse[2])% mod)

0