結果

問題 No.1964 sum = length
ユーザー rlangevinrlangevin
提出日時 2023-10-11 20:59:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,734 ms / 2,000 ms
コード長 1,423 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 86,564 KB
実行使用メモリ 258,644 KB
最終ジャッジ日時 2023-10-11 21:00:34
合計ジャッジ時間 40,436 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 166 ms
85,788 KB
testcase_01 AC 127 ms
81,984 KB
testcase_02 AC 327 ms
133,344 KB
testcase_03 AC 126 ms
81,752 KB
testcase_04 AC 191 ms
86,096 KB
testcase_05 AC 196 ms
89,244 KB
testcase_06 AC 193 ms
91,968 KB
testcase_07 AC 198 ms
95,696 KB
testcase_08 AC 207 ms
98,496 KB
testcase_09 AC 215 ms
101,744 KB
testcase_10 AC 251 ms
104,768 KB
testcase_11 AC 233 ms
108,028 KB
testcase_12 AC 511 ms
212,796 KB
testcase_13 AC 697 ms
258,240 KB
testcase_14 AC 868 ms
258,264 KB
testcase_15 AC 970 ms
258,264 KB
testcase_16 AC 289 ms
130,200 KB
testcase_17 AC 587 ms
231,796 KB
testcase_18 AC 609 ms
250,804 KB
testcase_19 AC 476 ms
190,320 KB
testcase_20 AC 474 ms
200,092 KB
testcase_21 AC 285 ms
127,028 KB
testcase_22 AC 1,612 ms
258,612 KB
testcase_23 AC 1,563 ms
258,500 KB
testcase_24 AC 1,239 ms
258,256 KB
testcase_25 AC 1,323 ms
258,396 KB
testcase_26 AC 1,633 ms
258,216 KB
testcase_27 AC 1,422 ms
258,376 KB
testcase_28 AC 1,300 ms
258,568 KB
testcase_29 AC 1,509 ms
258,580 KB
testcase_30 AC 1,341 ms
258,464 KB
testcase_31 AC 1,681 ms
258,616 KB
testcase_32 AC 1,065 ms
258,372 KB
testcase_33 AC 1,011 ms
258,336 KB
testcase_34 AC 1,584 ms
258,408 KB
testcase_35 AC 1,128 ms
258,392 KB
testcase_36 AC 1,409 ms
258,332 KB
testcase_37 AC 1,483 ms
258,408 KB
testcase_38 AC 1,702 ms
258,640 KB
testcase_39 AC 1,309 ms
258,644 KB
testcase_40 AC 1,333 ms
258,640 KB
testcase_41 AC 1,591 ms
258,412 KB
testcase_42 AC 1,734 ms
258,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
M = 450
mod = 998244353
pre = [0] * (M * M)
pre[0] = 1
def f(a, b):
    return a * M + b
    
for _ in range(N):
    dp = [0] * (M * M)
    Ac = [0] * (M * M)
    for i in range(M):
        for j in range(M):
            p = pre[f(i, j)]
            if i + 1 <= M - 1 and j + 2 <= M - 1: 
                dp[f(i + 1,j + 2)] += p
                dp[f(i + 1,j + 2)] %= mod
            if i + 10 <= M - 1 and j + 2 <= M - 1: 
                dp[f(i + 10,j + 2)] -= p
                dp[f(i + 10,j + 2)] %= mod
            if i + 10 <= M - 1 and j + 3 <= M - 1: 
                dp[f(i + 10,j + 3)] += p
                dp[f(i + 10,j + 3)] %= mod
            if i + 100 <= M - 1 and j + 3 <= M - 1: 
                dp[f(i + 100,j + 3)] -= p
                dp[f(i + 100,j + 3)] %= mod
            if i + 100 <= M - 1 and j + 4 <= M - 1: 
                dp[f(i + 100,j + 4)] += p
                dp[f(i + 100,j + 4)] %= mod
            # for n in range(1, M):
            #     num = len(str(n))
            #     if i + n <= M - 1 and j + num + 1 <= M - 1: 
            #         dp[f(i + n,j + num + 1] += p
            #         dp[f(i + n,j + num + 1] %= mod
    for i in range(1, M):
        for j in range(M):
            Ac[f(i,j)] = (Ac[f(i-1,j)] + dp[f(i,j)]) % mod
            
    Ac, pre = pre, Ac

ans = 0
for i in range(M - 1):
    ans += pre[f(i,i+1)]
    ans %= mod                

print(ans)
0