結果

問題 No.997 Jumping Kangaroo
コンテスト
ユーザー ああ
提出日時 2026-05-19 21:46:06
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 679 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 271 ms
コンパイル使用メモリ 85,168 KB
実行使用メモリ 60,160 KB
最終ジャッジ日時 2026-05-19 21:46:10
合計ジャッジ時間 2,446 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_1
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def aa(q,e):
    global mod
    res=[[0]*2 for i in range(2)]
    for i in range(2):
        for j in range(2):
            for l in range(2):
                res[j][l]+=q[j][i]*e[i][l]%mod
                res[j][l]%=mod
    return res
            

n,w,k=map(int,input().split())
mat=[[0]*2 for i in range(2)];mod=10**9+7
ans=[[0]*2 for i in range(2)];ans[0][0]=1
a=list(map(int,input().split()))
dp=[0]*(w*2+1);dp[0]=1
for i in range(w*2):
    if w==i:
        continue
    for j in a:
        if i+j<=w*2:
            dp[i+j]+=dp[i]
mat[0][0]=dp[w]%mod
mat[1][0]=1;mat[0][1]=dp[w*2]%mod
while k:
    if k&1:
        ans=aa(ans,mat)
    k>>=1;mat=aa(mat,mat)
print(ans[0][0])

0