結果

問題 No.1964 sum = length
ユーザー kokatsukokatsu
提出日時 2022-06-03 22:32:47
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 544 ms / 2,000 ms
コード長 711 bytes
コンパイル時間 2,938 ms
コンパイル使用メモリ 199,768 KB
実行使用メモリ 6,660 KB
最終ジャッジ日時 2023-09-04 17:21:38
合計ジャッジ時間 10,962 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 6 ms
4,384 KB
testcase_13 AC 15 ms
4,380 KB
testcase_14 AC 37 ms
4,384 KB
testcase_15 AC 55 ms
4,384 KB
testcase_16 AC 2 ms
4,384 KB
testcase_17 AC 8 ms
4,380 KB
testcase_18 AC 11 ms
4,380 KB
testcase_19 AC 4 ms
4,384 KB
testcase_20 AC 5 ms
4,384 KB
testcase_21 AC 2 ms
4,384 KB
testcase_22 AC 417 ms
4,884 KB
testcase_23 AC 390 ms
4,840 KB
testcase_24 AC 151 ms
4,476 KB
testcase_25 AC 199 ms
4,608 KB
testcase_26 AC 467 ms
4,860 KB
testcase_27 AC 268 ms
4,572 KB
testcase_28 AC 181 ms
4,424 KB
testcase_29 AC 334 ms
4,608 KB
testcase_30 AC 201 ms
4,656 KB
testcase_31 AC 469 ms
6,660 KB
testcase_32 AC 75 ms
4,388 KB
testcase_33 AC 69 ms
4,380 KB
testcase_34 AC 384 ms
4,884 KB
testcase_35 AC 107 ms
4,380 KB
testcase_36 AC 229 ms
4,632 KB
testcase_37 AC 322 ms
4,580 KB
testcase_38 AC 516 ms
4,888 KB
testcase_39 AC 190 ms
4,496 KB
testcase_40 AC 206 ms
4,552 KB
testcase_41 AC 431 ms
4,880 KB
testcase_42 AC 544 ms
4,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main() {
    long n;
    readf("%d\n", n);

    long M = 998244353;

    void addMod(ref long x, long y) {
        x += y;
        if (x >= M) x %= M;
    }

    long w = n * 2 + 1, l = w * 2;

    auto dp = new long[][](n+1, l+1);
    dp[0][w] = 1;
    foreach (i; 0 .. n) {
        foreach (j; 0 .. l+1) {
            foreach (k; 1 .. w-i+1) {
                long a, t = k;
                while (t > 0) {
                    ++a;
                    t /= 10;
                }

                if (i > 0) ++a;

                long p = j + k - a;
                if (0 <= p && p <= l) addMod(dp[i+1][p], dp[i][j]);
            }
        }
    }

    long res = dp[n][w];
    res.writeln;
}
0