結果

問題 No.1964 sum = length
ユーザー maguroflymagurofly
提出日時 2022-06-04 13:27:18
言語 Ruby
(3.3.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 453 bytes
コンパイル時間 505 ms
コンパイル使用メモリ 11,808 KB
実行使用メモリ 16,144 KB
最終ジャッジ日時 2023-10-21 02:39:33
合計ジャッジ時間 28,476 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
16,028 KB
testcase_01 AC 86 ms
16,028 KB
testcase_02 AC 86 ms
16,028 KB
testcase_03 AC 86 ms
16,028 KB
testcase_04 AC 86 ms
16,028 KB
testcase_05 AC 85 ms
16,028 KB
testcase_06 AC 86 ms
16,028 KB
testcase_07 AC 86 ms
16,028 KB
testcase_08 AC 86 ms
16,028 KB
testcase_09 AC 86 ms
16,028 KB
testcase_10 AC 88 ms
16,028 KB
testcase_11 AC 87 ms
16,024 KB
testcase_12 AC 105 ms
16,028 KB
testcase_13 AC 144 ms
16,128 KB
testcase_14 AC 221 ms
16,028 KB
testcase_15 AC 283 ms
16,028 KB
testcase_16 AC 89 ms
16,028 KB
testcase_17 AC 114 ms
16,128 KB
testcase_18 AC 127 ms
16,128 KB
testcase_19 AC 99 ms
16,028 KB
testcase_20 AC 101 ms
16,028 KB
testcase_21 AC 87 ms
16,028 KB
testcase_22 AC 1,581 ms
16,144 KB
testcase_23 AC 1,482 ms
16,144 KB
testcase_24 AC 616 ms
16,144 KB
testcase_25 AC 785 ms
16,144 KB
testcase_26 AC 1,769 ms
16,144 KB
testcase_27 AC 1,037 ms
16,144 KB
testcase_28 AC 727 ms
16,144 KB
testcase_29 AC 1,279 ms
16,144 KB
testcase_30 AC 795 ms
16,144 KB
testcase_31 AC 1,775 ms
16,144 KB
testcase_32 AC 349 ms
16,144 KB
testcase_33 AC 327 ms
16,144 KB
testcase_34 AC 1,462 ms
16,144 KB
testcase_35 AC 464 ms
16,144 KB
testcase_36 AC 899 ms
16,144 KB
testcase_37 AC 1,235 ms
16,144 KB
testcase_38 AC 1,940 ms
16,144 KB
testcase_39 AC 754 ms
16,144 KB
testcase_40 AC 812 ms
16,144 KB
testcase_41 AC 1,635 ms
16,144 KB
testcase_42 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

MOD = 998244353
n = gets.to_i

d = ->(n) {
    case n
    when 1 .. 9
        1
    when 10 .. 99
        2
    when 100 .. 999
        3
    when 1000 .. 9999
        4
    end
}

dp = [0] * n
dp[0] = 1
n.times do
    dp2 = [0] * n
    (0 ... n).each do |i|
        (1 .. 999).each do |a|
            x = a - d[a]
            break if i < x
            dp2[i] += dp[i - x]
            dp2[i] %= MOD
        end
    end
    dp = dp2
end


puts dp[n - 1]
0