結果

問題 No.612 Move on grid
ユーザー brthyyjp
提出日時 2022-03-28 18:02:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 821 ms / 2,500 ms
コード長 715 bytes
コンパイル時間 370 ms
コンパイル使用メモリ 82,520 KB
実行使用メモリ 137,200 KB
最終ジャッジ日時 2024-11-07 09:28:38
合計ジャッジ時間 8,805 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

def main():

    t = int(input())
    a,b,c,d,e = map(int, input().split())
    from collections import defaultdict
    mod = 10**9+7
    N = 10**4+50
    dp = [0]*(2*N+1)
    dp[N] = 1
    for i in range(t):
        ndp = [0]*(2*N+1)
        for k in range(2*N+1):
            if dp[k] == 0:
                continue
            for dk in [a, -a, b, -b, c, -c]:
                if 0 <= k+dk <= 2*N:
                    ndp[k+dk] += dp[k]
                    ndp[k+dk] %= mod
        dp = ndp
    ans = 0
    for i in range(d, e+1):
        ans += dp[N+i]
        ans %= mod
    print(ans)

if __name__ == '__main__':
    main()
0