結果

問題 No.997 Jumping Kangaroo
ユーザー rlangevinrlangevin
提出日時 2023-08-29 12:42:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 929 bytes
コンパイル時間 2,045 ms
コンパイル使用メモリ 86,636 KB
実行使用メモリ 76,052 KB
最終ジャッジ日時 2023-08-29 12:42:20
合計ジャッジ時間 5,518 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,288 KB
testcase_01 AC 70 ms
71,468 KB
testcase_02 AC 71 ms
71,236 KB
testcase_03 AC 70 ms
71,448 KB
testcase_04 AC 70 ms
71,136 KB
testcase_05 AC 70 ms
71,448 KB
testcase_06 AC 69 ms
71,256 KB
testcase_07 AC 69 ms
71,428 KB
testcase_08 AC 69 ms
71,136 KB
testcase_09 AC 69 ms
71,244 KB
testcase_10 AC 71 ms
71,536 KB
testcase_11 AC 72 ms
71,096 KB
testcase_12 AC 71 ms
71,248 KB
testcase_13 AC 72 ms
70,972 KB
testcase_14 AC 72 ms
71,192 KB
testcase_15 AC 69 ms
71,408 KB
testcase_16 AC 76 ms
75,832 KB
testcase_17 AC 69 ms
71,300 KB
testcase_18 AC 76 ms
75,860 KB
testcase_19 AC 70 ms
71,332 KB
testcase_20 AC 77 ms
75,976 KB
testcase_21 AC 70 ms
71,336 KB
testcase_22 AC 77 ms
75,972 KB
testcase_23 AC 76 ms
76,052 KB
testcase_24 AC 70 ms
71,272 KB
testcase_25 AC 70 ms
71,224 KB
testcase_26 AC 71 ms
71,408 KB
testcase_27 AC 69 ms
71,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

def Matprod(A, B, mod, N):
    temp = [0] * N*N
    for i in range(N):
        for j in range(N):
            ij = i * N + j
            for k in range(N):
                temp[ij] += A[i*N+k] * B[k*N+j]
                temp[ij] %= mod
    return temp

def Matpow_Linear(A, M, mod, N):
    Mat = [0] * N*N
    for i in range(N):
        Mat[i*N+i] = 1
         
    while M:
        if M & 1:
            Mat = Matprod(Mat, A, mod, N)
        A = Matprod(A, A, mod, N)
        M >>= 1
    return Mat  


N, W, K = map(int, input().split())
mod = 10 ** 9 + 7
A = list(map(int, input().split()))
dp = [0] * (2 * W + 1)
dp[0] = 1
for i in range(1, 2 * W + 1):
    for a in A:
        if i - a >= 0:
            dp[i] += dp[i - a]
            dp[i] %= mod

f1 = dp[W]
f2 = dp[2 * W] - f1**2
f2 %= mod
F = [f1, f2, 1, 0]

F = Matpow_Linear(F, K - 1, mod, 2)
ans = F[0] * f1 + F[1]
print(ans%mod)
0