結果

問題 No.995 タピオカオイシクナーレ
ユーザー H3PO4H3PO4
提出日時 2023-07-15 09:40:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 171 ms / 2,000 ms
コード長 772 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 10,900 KB
実行使用メモリ 29,712 KB
最終ジャッジ日時 2023-10-15 00:22:23
合計ジャッジ時間 7,686 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
29,520 KB
testcase_01 AC 124 ms
29,704 KB
testcase_02 AC 125 ms
29,636 KB
testcase_03 AC 122 ms
29,600 KB
testcase_04 AC 123 ms
29,580 KB
testcase_05 AC 120 ms
29,636 KB
testcase_06 AC 124 ms
29,680 KB
testcase_07 AC 121 ms
29,592 KB
testcase_08 AC 120 ms
29,520 KB
testcase_09 AC 120 ms
29,636 KB
testcase_10 AC 121 ms
29,592 KB
testcase_11 AC 124 ms
29,516 KB
testcase_12 AC 122 ms
29,708 KB
testcase_13 AC 119 ms
29,624 KB
testcase_14 AC 119 ms
29,712 KB
testcase_15 AC 120 ms
29,624 KB
testcase_16 AC 165 ms
29,712 KB
testcase_17 AC 163 ms
29,580 KB
testcase_18 AC 162 ms
29,672 KB
testcase_19 AC 171 ms
29,704 KB
testcase_20 AC 165 ms
29,588 KB
testcase_21 AC 169 ms
29,676 KB
testcase_22 AC 162 ms
29,560 KB
testcase_23 AC 165 ms
29,712 KB
testcase_24 AC 162 ms
29,560 KB
testcase_25 AC 162 ms
29,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np

input = sys.stdin.buffer.readline

MOD = 10 ** 9 + 7
modinv = lambda a, mod=MOD: pow(a, -1, mod)


def pow_matrix_mod(x, n, mod=MOD):
    x = x.astype(object)
    if not n:
        return np.eye(len(x), dtype=object)
    if n % 2 == 0:
        return pow_matrix_mod(x @ x % mod, n // 2) % mod
    else:
        return x @ pow_matrix_mod(x @ x % mod, (n - 1) // 2) % mod


N, M, K, P, Q = map(int, input().split())
pq = P * modinv(Q) % MOD
matr = np.array([[(1 - pq) % MOD, pq], [pq, (1 - pq) % MOD]], dtype=np.int64)
tea = 0
kitchen = 0
for _ in range(M):
    tea += int(input())
for _ in range(N - M):
    kitchen += int(input())
tea %= MOD
kitchen %= MOD
ans = (np.array([tea, kitchen]) @ pow_matrix_mod(matr, K))[0]
ans %= MOD
print(ans)
0