結果

問題 No.612 Move on grid
ユーザー りあんりあん
提出日時 2017-12-01 18:46:36
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 306 ms / 2,500 ms
コード長 624 bytes
コンパイル時間 384 ms
コンパイル使用メモリ 86,780 KB
実行使用メモリ 154,932 KB
最終ジャッジ日時 2023-08-22 22:09:55
合計ジャッジ時間 5,687 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
75,920 KB
testcase_01 AC 80 ms
76,076 KB
testcase_02 AC 79 ms
76,820 KB
testcase_03 AC 116 ms
94,864 KB
testcase_04 AC 204 ms
154,916 KB
testcase_05 AC 300 ms
154,932 KB
testcase_06 AC 304 ms
154,544 KB
testcase_07 AC 202 ms
154,508 KB
testcase_08 AC 306 ms
154,852 KB
testcase_09 AC 248 ms
154,780 KB
testcase_10 AC 187 ms
125,364 KB
testcase_11 AC 123 ms
99,244 KB
testcase_12 AC 229 ms
134,824 KB
testcase_13 AC 153 ms
109,240 KB
testcase_14 AC 265 ms
144,364 KB
testcase_15 AC 127 ms
100,660 KB
testcase_16 AC 292 ms
154,000 KB
testcase_17 AC 143 ms
110,788 KB
testcase_18 AC 260 ms
146,016 KB
testcase_19 AC 184 ms
130,108 KB
testcase_20 AC 223 ms
150,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
a, b, c, d, e = map(int, input().split())
M = 1000000007
m = 20020
s = 10010
dp = [0 for i in range(m)]
dp[s] = 1
for i in range(t):
    nex = [0 for i in range(m)]
    for j in range(m):
        if dp[j] > 0:
            nex[j + a] = (nex[j + a] + dp[j]) % M
            nex[j - a] = (nex[j - a] + dp[j]) % M
            nex[j + b] = (nex[j + b] + dp[j]) % M
            nex[j - b] = (nex[j - b] + dp[j]) % M
            nex[j + c] = (nex[j + c] + dp[j]) % M
            nex[j - c] = (nex[j - c] + dp[j]) % M

    dp = nex

ans = 0
for i in range(s + d, s + e + 1):
    ans = (ans + dp[i]) % M

print(ans)
0