結果

問題 No.612 Move on grid
ユーザー vwxyzvwxyz
提出日時 2022-04-10 16:21:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 668 ms / 2,500 ms
コード長 430 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 97,980 KB
最終ジャッジ日時 2023-12-26 06:07:38
合計ジャッジ時間 8,421 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 41 ms
53,460 KB
testcase_02 AC 39 ms
53,460 KB
testcase_03 AC 80 ms
75,196 KB
testcase_04 AC 668 ms
97,852 KB
testcase_05 AC 667 ms
97,724 KB
testcase_06 AC 663 ms
97,980 KB
testcase_07 AC 659 ms
97,724 KB
testcase_08 AC 667 ms
97,980 KB
testcase_09 AC 329 ms
80,044 KB
testcase_10 AC 259 ms
79,532 KB
testcase_11 AC 105 ms
75,580 KB
testcase_12 AC 393 ms
84,780 KB
testcase_13 AC 169 ms
77,100 KB
testcase_14 AC 515 ms
90,324 KB
testcase_15 AC 116 ms
75,704 KB
testcase_16 AC 586 ms
93,284 KB
testcase_17 AC 173 ms
77,228 KB
testcase_18 AC 481 ms
88,236 KB
testcase_19 AC 297 ms
80,940 KB
testcase_20 AC 410 ms
83,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline=sys.stdin.readline

T=int(readline())
mod=10**9+7
a,b,c,d,e=map(int,readline().split())
m=max(abs(x) for x in (a,b,c))
M=m*T
dp=[0]*(2*M+1)
dp[M]=1
for t in range(T):
    prev=dp
    dp=[0]*(2*M+1)
    for i in range(2*M+1):
        for di in (a,-a,b,-b,c,-c):
            if 0<=i+di<2*M+1:
                dp[i+di]+=prev[i]
                dp[i+di]%=mod
ans=sum(dp[max(d+M,0):min(e+M+1,2*M+1)])%mod
print(ans)
0