結果

問題 No.612 Move on grid
ユーザー りあん
提出日時 2017-12-01 18:46:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 272 ms / 2,500 ms
コード長 624 bytes
コンパイル時間 1,623 ms
コンパイル使用メモリ 81,744 KB
実行使用メモリ 143,752 KB
最終ジャッジ日時 2024-12-18 00:43:47
合計ジャッジ時間 5,752 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
a, b, c, d, e = map(int, input().split())
M = 1000000007
m = 20020
s = 10010
dp = [0 for i in range(m)]
dp[s] = 1
for i in range(t):
    nex = [0 for i in range(m)]
    for j in range(m):
        if dp[j] > 0:
            nex[j + a] = (nex[j + a] + dp[j]) % M
            nex[j - a] = (nex[j - a] + dp[j]) % M
            nex[j + b] = (nex[j + b] + dp[j]) % M
            nex[j - b] = (nex[j - b] + dp[j]) % M
            nex[j + c] = (nex[j + c] + dp[j]) % M
            nex[j - c] = (nex[j - c] + dp[j]) % M

    dp = nex

ans = 0
for i in range(s + d, s + e + 1):
    ans = (ans + dp[i]) % M

print(ans)
0