結果

問題 No.1964 sum = length
ユーザー mkawa2mkawa2
提出日時 2022-06-03 22:06:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,933 ms / 2,000 ms
コード長 1,664 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 81,816 KB
実行使用メモリ 221,012 KB
最終ジャッジ日時 2023-10-21 01:54:27
合計ジャッジ時間 33,187 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
77,820 KB
testcase_01 AC 66 ms
70,776 KB
testcase_02 AC 178 ms
79,960 KB
testcase_03 AC 67 ms
70,780 KB
testcase_04 AC 97 ms
77,820 KB
testcase_05 AC 104 ms
77,888 KB
testcase_06 AC 111 ms
77,928 KB
testcase_07 AC 120 ms
78,648 KB
testcase_08 AC 128 ms
78,704 KB
testcase_09 AC 132 ms
78,744 KB
testcase_10 AC 133 ms
78,760 KB
testcase_11 AC 146 ms
80,292 KB
testcase_12 AC 251 ms
85,440 KB
testcase_13 AC 340 ms
89,540 KB
testcase_14 AC 472 ms
94,332 KB
testcase_15 AC 599 ms
103,612 KB
testcase_16 AC 160 ms
79,984 KB
testcase_17 AC 291 ms
86,876 KB
testcase_18 AC 309 ms
85,832 KB
testcase_19 AC 225 ms
82,820 KB
testcase_20 AC 230 ms
82,908 KB
testcase_21 AC 148 ms
80,048 KB
testcase_22 AC 1,633 ms
193,212 KB
testcase_23 AC 1,544 ms
184,396 KB
testcase_24 AC 932 ms
127,740 KB
testcase_25 AC 1,087 ms
133,696 KB
testcase_26 AC 1,776 ms
212,932 KB
testcase_27 AC 1,273 ms
148,564 KB
testcase_28 AC 1,015 ms
135,188 KB
testcase_29 AC 1,470 ms
170,120 KB
testcase_30 AC 1,134 ms
132,364 KB
testcase_31 AC 1,746 ms
212,928 KB
testcase_32 AC 632 ms
108,316 KB
testcase_33 AC 616 ms
105,128 KB
testcase_34 AC 1,526 ms
184,856 KB
testcase_35 AC 779 ms
115,160 KB
testcase_36 AC 1,133 ms
146,848 KB
testcase_37 AC 1,393 ms
167,380 KB
testcase_38 AC 1,827 ms
215,304 KB
testcase_39 AC 1,040 ms
132,696 KB
testcase_40 AC 1,115 ms
144,608 KB
testcase_41 AC 1,670 ms
199,180 KB
testcase_42 AC 1,933 ms
221,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
# md = 10**9+7
md = 998244353

n = II()

m = n+230
dp = [[0]*m for _ in range(m)]
ss = [[0]*(m+1) for _ in range(m)]
dp[0][0] = 1
ss[0] = [0]+[1]*m

for t in range(n):
    ndp = [[0]*m for _ in range(m)]
    nss = [[0]*(m+1) for _ in range(m)]
    for i in range(1, m):
        for j in range(1, m):
            # ndp[i][j] += sum(dp[i-2][j-1, j-9])
            l, pi = max(0, j-9), i-2+(t == 0)
            if pi >= 0: ndp[i][j] += ss[pi][j]-ss[pi][l]
            # ndp[i][j] += sum(dp[i-3][j-10, j-99])
            l, pi = max(0, j-99), i-3+(t == 0)
            if pi >= 0 and j-9>=0: ndp[i][j] += ss[pi][j-9]-ss[pi][l]
            # ndp[i][j] += sum(dp[i-4][j-100, j-999])
            l, pi = max(0, j-999), i-4+(t == 0)
            if pi >= 0 and j-99>=0: ndp[i][j] += ss[pi][j-99]-ss[pi][l]
            nss[i][j+1] = (nss[i][j]+ndp[i][j])%md
    dp,ss=ndp,nss
    # p2D(dp)

ans=0
for i in range(m):
    # print(i,dp[i][i])
    ans+=dp[i][i]
    ans%=md

print(ans)
0