結果

問題 No.1964 sum = length
ユーザー maguroflymagurofly
提出日時 2022-06-04 13:29:16
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,682 ms / 2,000 ms
コード長 447 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 11,840 KB
実行使用メモリ 16,204 KB
最終ジャッジ日時 2023-10-21 02:40:29
合計ジャッジ時間 25,120 ms
ジャッジサーバーID
(参考情報)
judge10 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
16,028 KB
testcase_01 AC 75 ms
16,028 KB
testcase_02 AC 78 ms
16,028 KB
testcase_03 AC 74 ms
16,028 KB
testcase_04 AC 75 ms
16,028 KB
testcase_05 AC 78 ms
16,028 KB
testcase_06 AC 79 ms
16,028 KB
testcase_07 AC 80 ms
16,028 KB
testcase_08 AC 83 ms
16,028 KB
testcase_09 AC 78 ms
16,028 KB
testcase_10 AC 78 ms
16,028 KB
testcase_11 AC 78 ms
16,028 KB
testcase_12 AC 96 ms
16,128 KB
testcase_13 AC 128 ms
16,128 KB
testcase_14 AC 186 ms
16,028 KB
testcase_15 AC 241 ms
16,028 KB
testcase_16 AC 77 ms
16,028 KB
testcase_17 AC 103 ms
16,128 KB
testcase_18 AC 107 ms
16,128 KB
testcase_19 AC 86 ms
16,028 KB
testcase_20 AC 88 ms
16,028 KB
testcase_21 AC 76 ms
16,028 KB
testcase_22 AC 1,346 ms
16,200 KB
testcase_23 AC 1,267 ms
16,200 KB
testcase_24 AC 511 ms
16,200 KB
testcase_25 AC 659 ms
16,200 KB
testcase_26 AC 1,488 ms
16,204 KB
testcase_27 AC 855 ms
16,204 KB
testcase_28 AC 612 ms
16,200 KB
testcase_29 AC 1,058 ms
16,204 KB
testcase_30 AC 665 ms
16,200 KB
testcase_31 AC 1,450 ms
16,204 KB
testcase_32 AC 307 ms
16,200 KB
testcase_33 AC 278 ms
16,200 KB
testcase_34 AC 1,204 ms
16,204 KB
testcase_35 AC 377 ms
16,200 KB
testcase_36 AC 733 ms
16,204 KB
testcase_37 AC 1,013 ms
16,200 KB
testcase_38 AC 1,606 ms
16,204 KB
testcase_39 AC 626 ms
16,204 KB
testcase_40 AC 668 ms
16,204 KB
testcase_41 AC 1,341 ms
16,204 KB
testcase_42 AC 1,682 ms
16,200 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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]
        end
    end
    dp = dp2.map { |x| x % MOD }
end


puts dp[n - 1]
0