結果

問題 No.612 Move on grid
ユーザー zimphazimpha
提出日時 2017-12-12 00:18:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 285 ms / 2,500 ms
コード長 523 bytes
コンパイル時間 662 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 155,644 KB
最終ジャッジ日時 2023-08-22 22:11:01
合計ジャッジ時間 5,657 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
76,488 KB
testcase_01 AC 86 ms
76,776 KB
testcase_02 AC 87 ms
77,256 KB
testcase_03 AC 137 ms
95,624 KB
testcase_04 AC 251 ms
155,020 KB
testcase_05 AC 261 ms
155,504 KB
testcase_06 AC 281 ms
155,628 KB
testcase_07 AC 278 ms
155,596 KB
testcase_08 AC 276 ms
155,644 KB
testcase_09 AC 285 ms
155,560 KB
testcase_10 AC 211 ms
125,916 KB
testcase_11 AC 148 ms
99,548 KB
testcase_12 AC 236 ms
135,392 KB
testcase_13 AC 176 ms
109,816 KB
testcase_14 AC 251 ms
145,088 KB
testcase_15 AC 150 ms
101,652 KB
testcase_16 AC 277 ms
154,536 KB
testcase_17 AC 178 ms
111,540 KB
testcase_18 AC 263 ms
146,528 KB
testcase_19 AC 225 ms
130,988 KB
testcase_20 AC 278 ms
151,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10 ** 9 + 7
T = int(input())
a, b, c, d, e = list(map(int, input().split()))
a = abs(a)
b = abs(b)
c = abs(c)
n, offset = 20000 + 2, 10000
f = [0] * n
f[offset] = 1
for i in range(T):
  g = [0] * n
  for j in range(n):
    f[j] %= mod
    if j >= a: g[j - a] += f[j]
    if j >= b: g[j - b] += f[j]
    if j >= c: g[j - c] += f[j]
    if j + a < n: g[j + a] += f[j]
    if j + b < n: g[j + b] += f[j]
    if j + c < n: g[j + c] += f[j]
  f = g
ret = 0
for i in range(d, e + 1):
  ret += g[i + offset]
print(ret % mod)
0