結果
| 問題 | No.612 Move on grid |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-12 10:32:18 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 2,149 ms / 2,500 ms |
| コード長 | 715 bytes |
| 記録 | |
| コンパイル時間 | 170 ms |
| コンパイル使用メモリ | 82,116 KB |
| 実行使用メモリ | 157,316 KB |
| 最終ジャッジ日時 | 2025-12-05 13:14:09 |
| 合計ジャッジ時間 | 18,515 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 18 |
ソースコード
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# †
from collections import defaultdict
mod = 10**9 + 7
T = int(input())
a, b, c, d, e = map(int, input().split())
dp = defaultdict(int)
dp[0] = 1
for t in range(T):
ndp = defaultdict(int)
for cur in dp.keys():
ndp[cur + a] += dp[cur]
ndp[cur + a] %= mod
ndp[cur - a] += dp[cur]
ndp[cur - a] %= mod
ndp[cur + b] += dp[cur]
ndp[cur + b] %= mod
ndp[cur - b] += dp[cur]
ndp[cur - b] %= mod
ndp[cur + c] += dp[cur]
ndp[cur + c] %= mod
ndp[cur - c] += dp[cur]
ndp[cur - c] %= mod
dp = ndp
res = 0
for r in range(d, e+1):
res += dp[r]
res %= mod
print(res)