結果

問題 No.1964 sum = length
ユーザー tktk_snsntktk_snsn
提出日時 2022-06-03 23:12:30
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 923 bytes
コンパイル時間 250 ms
コンパイル使用メモリ 81,724 KB
実行使用メモリ 78,568 KB
最終ジャッジ日時 2023-10-21 02:23:07
合計ジャッジ時間 13,311 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
55,576 KB
testcase_01 AC 42 ms
55,576 KB
testcase_02 AC 66 ms
68,752 KB
testcase_03 AC 42 ms
55,576 KB
testcase_04 AC 42 ms
55,576 KB
testcase_05 AC 43 ms
55,576 KB
testcase_06 AC 45 ms
55,576 KB
testcase_07 AC 43 ms
55,576 KB
testcase_08 AC 43 ms
55,576 KB
testcase_09 AC 44 ms
55,576 KB
testcase_10 AC 45 ms
55,576 KB
testcase_11 AC 50 ms
62,124 KB
testcase_12 AC 98 ms
76,216 KB
testcase_13 AC 158 ms
76,536 KB
testcase_14 AC 284 ms
76,888 KB
testcase_15 AC 321 ms
77,132 KB
testcase_16 AC 65 ms
68,724 KB
testcase_17 AC 107 ms
76,244 KB
testcase_18 AC 129 ms
76,284 KB
testcase_19 AC 83 ms
76,164 KB
testcase_20 AC 86 ms
76,172 KB
testcase_21 AC 66 ms
68,724 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
mod = 998244353
U = 211


def id(x, y):
    return x * U + y


def parse(x):
    a = x // U
    return a, x - U * a


def dec(x):
    if x < 10:
        return 1
    if x < 100:
        return 2
    return 3


"""
sum + 1 == len

1: sum += 1, len += 2
2: sum += 2, len += 2
x: sum += x, len += dec(x) + 1
"""


n = int(input())
dp = defaultdict(int)
dp[0] = 1
for i in range(n):
    # ok = n - i - 1 + 10
    ndp = defaultdict(int)
    for k, v in dp.items():
        s, l = parse(k)
        for a in range(1, U):
            ns = s + a
            nl = l + dec(a) + 1
            if ns >= U or nl >= U:
                break
            if ns - nl > n:
                break
            nk = id(ns, nl)
            ndp[nk] += v
            ndp[nk] %= mod
    dp = ndp

ans = 0
for k, v in dp.items():
    s, l = parse(k)
    if s + 1 == l:
        ans += v
        ans %= mod
print(ans)
0