結果

問題 No.612 Move on grid
ユーザー 👑 rin204rin204
提出日時 2022-02-14 08:57:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,223 ms / 2,500 ms
コード長 443 bytes
コンパイル時間 601 ms
コンパイル使用メモリ 87,040 KB
実行使用メモリ 179,240 KB
最終ジャッジ日時 2023-09-11 15:49:13
合計ジャッジ時間 19,226 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
70,792 KB
testcase_01 AC 77 ms
70,864 KB
testcase_02 AC 77 ms
70,988 KB
testcase_03 AC 163 ms
76,760 KB
testcase_04 AC 193 ms
76,896 KB
testcase_05 AC 2,095 ms
179,240 KB
testcase_06 AC 2,219 ms
178,892 KB
testcase_07 AC 135 ms
76,656 KB
testcase_08 AC 2,223 ms
179,076 KB
testcase_09 AC 868 ms
99,252 KB
testcase_10 AC 656 ms
95,408 KB
testcase_11 AC 227 ms
78,460 KB
testcase_12 AC 1,186 ms
123,060 KB
testcase_13 AC 437 ms
84,396 KB
testcase_14 AC 1,751 ms
148,088 KB
testcase_15 AC 269 ms
79,512 KB
testcase_16 AC 1,766 ms
158,744 KB
testcase_17 AC 270 ms
78,436 KB
testcase_18 AC 1,548 ms
137,176 KB
testcase_19 AC 447 ms
82,824 KB
testcase_20 AC 602 ms
86,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7

T = int(input())
a, b, c, d, e = map(int, input().split())
dp = {0:1}
for _ in range(T):
    dp2 = {}
    for k, v in dp.items():
        for x in [a, b, c]:
            dp2[k + x] = dp2.get(k + x, 0) + v
            dp2[k - x] = dp2.get(k - x, 0) + v
            dp2[k + x] %= MOD
            dp2[k - x] %= MOD
    dp = dp2

ans = 0
for k, v in dp.items():
    if d <= k <= e:
        ans += v
        ans %= MOD
print(ans)
0