結果

問題 No.612 Move on grid
ユーザー zimphazimpha
提出日時 2017-12-12 00:18:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 266 ms / 2,500 ms
コード長 523 bytes
コンパイル時間 767 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 149,492 KB
最終ジャッジ日時 2024-05-10 03:43:52
合計ジャッジ時間 4,830 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
59,776 KB
testcase_01 AC 51 ms
62,464 KB
testcase_02 AC 53 ms
63,360 KB
testcase_03 AC 106 ms
84,736 KB
testcase_04 AC 228 ms
143,816 KB
testcase_05 AC 240 ms
145,280 KB
testcase_06 AC 257 ms
148,224 KB
testcase_07 AC 256 ms
144,768 KB
testcase_08 AC 256 ms
148,224 KB
testcase_09 AC 266 ms
149,492 KB
testcase_10 AC 183 ms
118,400 KB
testcase_11 AC 115 ms
89,216 KB
testcase_12 AC 212 ms
129,280 KB
testcase_13 AC 146 ms
101,760 KB
testcase_14 AC 227 ms
137,984 KB
testcase_15 AC 119 ms
91,648 KB
testcase_16 AC 256 ms
148,096 KB
testcase_17 AC 146 ms
104,576 KB
testcase_18 AC 239 ms
141,440 KB
testcase_19 AC 198 ms
124,160 KB
testcase_20 AC 249 ms
144,256 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