結果

問題 No.612 Move on grid
ユーザー yuppe19 😺yuppe19 😺
提出日時 2017-12-12 10:28:39
言語 PyPy2
(7.3.13)
結果
AC  
実行時間 2,050 ms / 2,500 ms
コード長 724 bytes
コンパイル時間 1,084 ms
コンパイル使用メモリ 77,280 KB
実行使用メモリ 170,580 KB
最終ジャッジ日時 2023-08-20 22:13:59
合計ジャッジ時間 19,533 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
78,056 KB
testcase_01 AC 82 ms
78,048 KB
testcase_02 AC 82 ms
78,076 KB
testcase_03 AC 195 ms
81,616 KB
testcase_04 AC 221 ms
83,400 KB
testcase_05 AC 1,954 ms
169,588 KB
testcase_06 AC 2,038 ms
170,116 KB
testcase_07 AC 169 ms
82,976 KB
testcase_08 AC 2,050 ms
170,580 KB
testcase_09 AC 904 ms
102,336 KB
testcase_10 AC 713 ms
98,140 KB
testcase_11 AC 264 ms
82,716 KB
testcase_12 AC 1,194 ms
122,832 KB
testcase_13 AC 448 ms
88,124 KB
testcase_14 AC 1,577 ms
145,240 KB
testcase_15 AC 302 ms
83,804 KB
testcase_16 AC 1,957 ms
154,816 KB
testcase_17 AC 305 ms
83,508 KB
testcase_18 AC 1,469 ms
137,204 KB
testcase_19 AC 521 ms
87,300 KB
testcase_20 AC 667 ms
90,592 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