結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
55,368 KB
testcase_01 AC 44 ms
55,368 KB
testcase_02 AC 69 ms
66,464 KB
testcase_03 AC 42 ms
55,368 KB
testcase_04 AC 42 ms
55,368 KB
testcase_05 AC 43 ms
55,368 KB
testcase_06 AC 41 ms
55,368 KB
testcase_07 AC 43 ms
55,368 KB
testcase_08 AC 41 ms
55,368 KB
testcase_09 AC 42 ms
55,368 KB
testcase_10 AC 42 ms
55,368 KB
testcase_11 AC 42 ms
55,368 KB
testcase_12 AC 86 ms
76,224 KB
testcase_13 AC 104 ms
76,048 KB
testcase_14 AC 138 ms
76,180 KB
testcase_15 AC 171 ms
76,120 KB
testcase_16 AC 61 ms
66,364 KB
testcase_17 AC 92 ms
76,084 KB
testcase_18 AC 94 ms
76,032 KB
testcase_19 AC 71 ms
70,592 KB
testcase_20 AC 73 ms
72,640 KB
testcase_21 AC 56 ms
66,392 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
    ndp = defaultdict(int)
    for k, v in dp.items():
        s, l = parse(k)
        for a in range(1, 201):
            ns = s + a
            nl = l + dec(a) + 1
            if ns >= U or nl >= U:
                break
            if ns - nl > ok:
                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