結果

問題 No.995 タピオカオイシクナーレ
ユーザー ああいいああいい
提出日時 2022-04-20 11:50:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 525 bytes
コンパイル時間 368 ms
コンパイル使用メモリ 86,904 KB
実行使用メモリ 78,936 KB
最終ジャッジ日時 2023-09-02 05:44:31
合計ジャッジ時間 5,622 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,272 KB
testcase_01 AC 72 ms
71,268 KB
testcase_02 AC 73 ms
71,456 KB
testcase_03 AC 73 ms
71,248 KB
testcase_04 AC 72 ms
70,936 KB
testcase_05 AC 72 ms
71,436 KB
testcase_06 AC 71 ms
70,932 KB
testcase_07 AC 72 ms
71,312 KB
testcase_08 AC 71 ms
71,156 KB
testcase_09 AC 71 ms
71,432 KB
testcase_10 AC 71 ms
71,220 KB
testcase_11 AC 79 ms
71,264 KB
testcase_12 AC 78 ms
71,376 KB
testcase_13 AC 78 ms
71,116 KB
testcase_14 AC 76 ms
71,228 KB
testcase_15 AC 77 ms
71,268 KB
testcase_16 AC 127 ms
78,064 KB
testcase_17 AC 130 ms
78,184 KB
testcase_18 AC 128 ms
78,364 KB
testcase_19 AC 126 ms
78,564 KB
testcase_20 AC 130 ms
78,468 KB
testcase_21 AC 129 ms
78,460 KB
testcase_22 AC 126 ms
78,460 KB
testcase_23 AC 126 ms
78,568 KB
testcase_24 AC 128 ms
78,936 KB
testcase_25 AC 130 ms
78,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M,K,p,q = map(int,input().split())
b = [int(input()) for _ in range(N)]
P = 10 ** 9 + 7
r = p * pow(q,P-2,P) % P
R = [[1-r,r],[r,1-r]]
e = [[1,0],[0,1]]
def seki(x,y):
    l = [[0] * 2 for _ in range(2)]
    for i in range(2):
        for j in range(2):
            for k in range(2):
                l[i][j] += x[i][k] * y[k][j] % P
            l[i][j] %= P
    return l
while K:
    if K & 1:
        e = seki(e,R)
    R = seki(R,R)
    K >>= 1
s = sum(b[:M])
t = sum(b) - s
ans = e[0][0] * s + e[0][1] * t
print(ans %P)
0