結果

問題 No.997 Jumping Kangaroo
ユーザー brthyyjpbrthyyjp
提出日時 2020-03-27 04:16:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 1,009 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 86,836 KB
実行使用メモリ 76,496 KB
最終ジャッジ日時 2023-08-30 16:02:09
合計ジャッジ時間 4,525 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,076 KB
testcase_01 AC 73 ms
71,116 KB
testcase_02 AC 76 ms
71,248 KB
testcase_03 AC 75 ms
71,588 KB
testcase_04 AC 74 ms
71,308 KB
testcase_05 AC 73 ms
70,996 KB
testcase_06 AC 75 ms
71,236 KB
testcase_07 AC 75 ms
71,200 KB
testcase_08 AC 74 ms
71,364 KB
testcase_09 AC 73 ms
71,504 KB
testcase_10 AC 75 ms
71,368 KB
testcase_11 AC 74 ms
71,440 KB
testcase_12 AC 73 ms
71,236 KB
testcase_13 AC 74 ms
71,480 KB
testcase_14 AC 74 ms
71,544 KB
testcase_15 AC 76 ms
71,088 KB
testcase_16 AC 80 ms
76,172 KB
testcase_17 AC 76 ms
71,476 KB
testcase_18 AC 81 ms
76,116 KB
testcase_19 AC 75 ms
71,380 KB
testcase_20 AC 81 ms
76,324 KB
testcase_21 AC 75 ms
71,236 KB
testcase_22 AC 83 ms
76,008 KB
testcase_23 AC 83 ms
76,496 KB
testcase_24 AC 73 ms
71,236 KB
testcase_25 AC 74 ms
71,436 KB
testcase_26 AC 73 ms
71,372 KB
testcase_27 AC 72 ms
71,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, w, k = map(int, input().split())
A = list(map(int, input().split()))
mod = 10**9+7

dp1 = [0]*(w+1)
dp2 = [0]*(2*w+1)

dp1[0] = 1
for i in range(1, w+1):
    for j in range(n):
        if i-A[j] >= 0:
            dp1[i] += dp1[i-A[j]]
            dp1[i] %= mod

dp2[0] = 1
for i in range(1, 2*w+1):
    if i == w:
        continue
    for j in range(n):
        if i-A[j] >= 0:
            dp2[i] += dp2[i-A[j]]
            dp2[i] %= mod

# A*B
def mul(a, b):
    c = [[0]*len(b[0]) for i in range(len(a))]
    for i in range(len(a)):
        for k in range(len(b)):
            for j in range(len(b[0])):
                c[i][j] = (c[i][j] + a[i][k]*b[k][j])%mod

    return c

#A**n
def pow(a, n):
    b = [[0]*len(a) for i in range(len(a))]
    for i in range(len(a)):
        b[i][i] = 1
    while n > 0:
        if n & 1 == 1:
            b = mul(a, b)
        a = mul(a, a)
        n = n>>1
    return b

X = [[dp1[-1], dp2[-1]], [1, 0]]
Y =  pow(X, k)
ans = Y[1][0]*dp1[-1]+Y[1][1]*1
print(ans%mod)
0