結果

問題 No.612 Move on grid
ユーザー vwxyzvwxyz
提出日時 2022-04-10 16:21:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 430 bytes
コンパイル時間 211 ms
コンパイル使用メモリ 10,832 KB
実行使用メモリ 12,776 KB
最終ジャッジ日時 2023-08-20 21:49:10
合計ジャッジ時間 5,882 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,736 KB
testcase_01 AC 17 ms
7,768 KB
testcase_02 AC 18 ms
7,836 KB
testcase_03 AC 1,122 ms
8,332 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

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