結果

問題 No.997 Jumping Kangaroo
ユーザー stngstng
提出日時 2022-08-20 11:42:11
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,105 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 76,672 KB
最終ジャッジ日時 2024-04-17 11:03:11
合計ジャッジ時間 4,364 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
58,496 KB
testcase_01 AC 41 ms
58,496 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 87 ms
73,216 KB
testcase_14 AC 222 ms
75,968 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 47 ms
62,336 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 37 ms
52,224 KB
testcase_27 AC 37 ms
52,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 行列の乗算(mod)
def mat_mul(a, b):
    I, K, J = len(a), len(b), len(b[0])
    c = [[0 for j in range(J)] for i in range(I)]
    for i in range(I):
        for k in range(K):
            for j in range(J):
                c[i][j] += a[i][k] * b[k][j]
                c[i][j] %= mod
    return c

# 行列の累乗(mod)
def mat_pow(a, n):
    b = [[0 for j in range(len(a))] for i in range(len(a))]
    for i in range(len(a)):
        b[i][i] = 1
    while n > 0:
        if n & 1:
            b = mat_mul(b, a)
        a = mat_mul(a, a)
        n >>= 1
    return b

n,w,K = map(int,input().split())
A = [int(i) for i in input().split()]

mod = 10**9+7

a = [[0]*(2*w+1) for i in range(2*w+1)]
aa = [[0]*(2*w+1) for i in range(2*w+1)]

aa[0][0] = 1

for i in range(2*w):
    for k in range(n):
        if i + A[k] <= 2*w:
            aa[i+A[k]][i+A[k]] += aa[i][i]
            aa[i+A[k]][i+A[k]] %= mod
        else:
            break

gr = mat_pow(aa,(K+1)//2)
ans = 0

for i in range(2*w+1):
    if K % 2 == 1:
        ans += gr[i][w]
    else:
        ans += gr[i][2*w]
    ans %= mod
print(ans)
0