結果

問題 No.612 Move on grid
ユーザー shotoyooshotoyoo
提出日時 2021-07-23 16:14:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 283 ms / 2,500 ms
コード長 794 bytes
コンパイル時間 989 ms
コンパイル使用メモリ 86,888 KB
実行使用メモリ 155,052 KB
最終ジャッジ日時 2023-09-25 15:00:37
合計ジャッジ時間 5,872 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
75,960 KB
testcase_01 AC 78 ms
76,312 KB
testcase_02 AC 78 ms
76,940 KB
testcase_03 AC 108 ms
95,236 KB
testcase_04 AC 175 ms
155,040 KB
testcase_05 AC 273 ms
154,740 KB
testcase_06 AC 279 ms
154,736 KB
testcase_07 AC 169 ms
154,916 KB
testcase_08 AC 283 ms
155,052 KB
testcase_09 AC 221 ms
155,052 KB
testcase_10 AC 174 ms
125,512 KB
testcase_11 AC 117 ms
99,488 KB
testcase_12 AC 210 ms
134,920 KB
testcase_13 AC 140 ms
109,508 KB
testcase_14 AC 240 ms
144,468 KB
testcase_15 AC 119 ms
100,736 KB
testcase_16 AC 266 ms
154,024 KB
testcase_17 AC 131 ms
110,968 KB
testcase_18 AC 236 ms
145,700 KB
testcase_19 AC 163 ms
130,328 KB
testcase_20 AC 192 ms
150,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


t = int(input())
a,b,c,d,e = list(map(int, input().split()))
m = 10000
dp = [0]*(2*m+1)
dp[m] = 1
M = 10**9+7
for i in range(t):
    ndp = [0]*(2*m+1)
    for j in range(2*m+1):
        val = dp[j]
        if val==0:
            continue
        ndp[j+a] = (ndp[j+a] + val) % M
        ndp[j-a] = (ndp[j-a] + val) % M
        ndp[j+b] = (ndp[j+b] + val) % M
        ndp[j-b] = (ndp[j-b] + val) % M
        ndp[j+c] = (ndp[j+c] + val) % M
        ndp[j-c] = (ndp[j-c] + val) % M
    dp = ndp
ans = 0
for i in range(d, e+1):
    ans += dp[i+m]
    ans %= M
print(ans%M)
0