結果

問題 No.612 Move on grid
ユーザー yuppe19 😺yuppe19 😺
提出日時 2017-12-12 10:28:39
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 2,122 ms / 2,500 ms
コード長 724 bytes
コンパイル時間 1,708 ms
コンパイル使用メモリ 76,928 KB
実行使用メモリ 170,120 KB
最終ジャッジ日時 2024-05-08 04:24:54
合計ジャッジ時間 20,449 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
77,344 KB
testcase_01 AC 93 ms
77,568 KB
testcase_02 AC 93 ms
77,856 KB
testcase_03 AC 200 ms
80,060 KB
testcase_04 AC 222 ms
82,176 KB
testcase_05 AC 2,035 ms
170,120 KB
testcase_06 AC 2,122 ms
170,112 KB
testcase_07 AC 169 ms
81,928 KB
testcase_08 AC 2,110 ms
169,644 KB
testcase_09 AC 928 ms
101,004 KB
testcase_10 AC 730 ms
97,480 KB
testcase_11 AC 271 ms
81,372 KB
testcase_12 AC 1,234 ms
122,340 KB
testcase_13 AC 471 ms
87,708 KB
testcase_14 AC 1,624 ms
144,996 KB
testcase_15 AC 309 ms
82,504 KB
testcase_16 AC 2,007 ms
154,324 KB
testcase_17 AC 313 ms
82,292 KB
testcase_18 AC 1,556 ms
136,304 KB
testcase_19 AC 534 ms
86,460 KB
testcase_20 AC 682 ms
89,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python2
# -*- coding: utf-8 -*-
# †
from collections import defaultdict

mod = 10**9 + 7

T = int(raw_input())
a, b, c, d, e = map(int, raw_input().split())
dp = defaultdict(int)
dp[0] = 1
for t in xrange(T):
    ndp = defaultdict(int)
    for cur in dp.keys():
        ndp[cur + a] += dp[cur]
        ndp[cur + a] %= mod
        ndp[cur - a] += dp[cur]
        ndp[cur - a] %= mod
        ndp[cur + b] += dp[cur]
        ndp[cur + b] %= mod
        ndp[cur - b] += dp[cur]
        ndp[cur - b] %= mod
        ndp[cur + c] += dp[cur]
        ndp[cur + c] %= mod
        ndp[cur - c] += dp[cur]
        ndp[cur - c] %= mod
    dp = ndp

res = 0
for r in xrange(d, e+1):
    res += dp[r]
    res %= mod
print res
0