結果

問題 No.612 Move on grid
ユーザー tktk_snsntktk_snsn
提出日時 2020-12-22 00:53:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 835 ms / 2,500 ms
コード長 661 bytes
コンパイル時間 371 ms
コンパイル使用メモリ 81,692 KB
実行使用メモリ 85,700 KB
最終ジャッジ日時 2023-10-21 12:19:05
合計ジャッジ時間 12,128 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
59,828 KB
testcase_01 AC 53 ms
64,404 KB
testcase_02 AC 58 ms
66,920 KB
testcase_03 AC 217 ms
81,656 KB
testcase_04 AC 658 ms
85,592 KB
testcase_05 AC 835 ms
85,700 KB
testcase_06 AC 813 ms
85,700 KB
testcase_07 AC 651 ms
85,580 KB
testcase_08 AC 812 ms
85,700 KB
testcase_09 AC 708 ms
85,424 KB
testcase_10 AC 495 ms
84,136 KB
testcase_11 AC 254 ms
82,128 KB
testcase_12 AC 604 ms
84,412 KB
testcase_13 AC 343 ms
83,008 KB
testcase_14 AC 701 ms
84,968 KB
testcase_15 AC 267 ms
82,016 KB
testcase_16 AC 799 ms
85,600 KB
testcase_17 AC 339 ms
83,056 KB
testcase_18 AC 710 ms
84,952 KB
testcase_19 AC 504 ms
84,040 KB
testcase_20 AC 664 ms
85,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10 ** 9 + 7
T = int(input())
a, b, c, d, e = map(int, input().split())
abc = (abs(a), abs(b), abs(c))

U = 10000
MAX = 2 * U + 1
dp = [0] * MAX
dp[U] = 1

while T:
    T -= 1
    newDP = [0] * MAX
    for i in range(MAX):
        for x in abc:
            if i + x < MAX:
                newDP[i + x] += dp[i]
                if newDP[i + x] >= mod:
                    newDP[i + x] -= mod
            if i - x >= 0:
                newDP[i - x] += dp[i]
                if newDP[i - x] >= mod:
                    newDP[i - x] -= mod
    dp = newDP

ans = 0
for i in range(d, e + 1):
    ans += dp[i + U]
    if ans >= mod:
        ans -= mod

print(ans)
0