結果

問題 No.995 タピオカオイシクナーレ
ユーザー maspymaspy
提出日時 2020-02-24 18:59:37
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 557 ms / 2,000 ms
コード長 551 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 48,160 KB
最終ジャッジ日時 2024-10-12 08:37:35
合計ジャッジ時間 17,540 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# %%
import numpy as np
# from numba import njit

# %%
N, M, K, p, q = map(int, readline().split())
B = np.array(read().split(), np.int64)

# %%
MOD = 10 ** 9 + 7
q_inv = pow(q, MOD - 2, MOD)
p_stay = 1 + pow((q - p - p) * q_inv, K, MOD)
p_stay *= pow(2, MOD - 2, MOD)
p_stay %= MOD

# %%
x = B[:M].sum() % MOD
y = B[M:].sum() % MOD
answer = p_stay * x + (1 - p_stay) * y
answer %= MOD
print(answer)

# %%
0