結果

問題 No.612 Move on grid
ユーザー maimai
提出日時 2017-12-12 02:29:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 220 ms / 2,500 ms
コード長 616 bytes
コンパイル時間 1,284 ms
コンパイル使用メモリ 86,684 KB
実行使用メモリ 155,072 KB
最終ジャッジ日時 2023-08-22 22:12:58
合計ジャッジ時間 4,373 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,636 KB
testcase_01 AC 74 ms
71,948 KB
testcase_02 AC 75 ms
72,368 KB
testcase_03 AC 96 ms
94,664 KB
testcase_04 AC 164 ms
154,784 KB
testcase_05 AC 220 ms
155,024 KB
testcase_06 AC 189 ms
154,904 KB
testcase_07 AC 161 ms
155,072 KB
testcase_08 AC 191 ms
154,700 KB
testcase_09 AC 161 ms
154,692 KB
testcase_10 AC 144 ms
125,404 KB
testcase_11 AC 101 ms
99,136 KB
testcase_12 AC 169 ms
134,696 KB
testcase_13 AC 113 ms
109,264 KB
testcase_14 AC 191 ms
144,180 KB
testcase_15 AC 100 ms
100,676 KB
testcase_16 AC 207 ms
153,908 KB
testcase_17 AC 114 ms
110,668 KB
testcase_18 AC 167 ms
145,964 KB
testcase_19 AC 142 ms
130,008 KB
testcase_20 AC 164 ms
150,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
a,b,c,d,e = map(int, input().split())

# print(t,a,b,c,d,e)

d += 10010
e += 10010

MD = 1000000007

dp = [0]*20020
dp[10010] = 1

left = 10010
right = 10011
abc = max(abs(a),abs(b),abs(c))

for lop in range(t):
    dp2 = [0]*20020
    for x in range(left, right):
        y = dp[x] = dp[x]%MD
        if y > 0:
            dp2[x + a] += y
            dp2[x - a] += y
            dp2[x + b] += y
            dp2[x - b] += y
            dp2[x + c] += y
            dp2[x - c] += y
    dp = dp2
    left -= abc
    right += abc

ans = 0
for x in range(d, e+1):
    ans = (ans+dp[x])%MD

print(ans%MD)
0