結果

問題 No.2131 Concon Substrings (COuNt Version)
ユーザー 👑 kakel-sankakel-san
提出日時 2023-09-25 22:57:32
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 357 ms / 2,000 ms
コード長 911 bytes
コンパイル時間 2,346 ms
コンパイル使用メモリ 67,412 KB
実行使用メモリ 97,008 KB
最終ジャッジ日時 2023-09-25 22:57:50
合計ジャッジ時間 5,371 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
20,620 KB
testcase_01 AC 54 ms
22,692 KB
testcase_02 AC 53 ms
20,548 KB
testcase_03 AC 191 ms
56,932 KB
testcase_04 AC 54 ms
20,588 KB
testcase_05 AC 54 ms
20,780 KB
testcase_06 AC 54 ms
20,648 KB
testcase_07 AC 357 ms
97,008 KB
testcase_08 AC 130 ms
40,256 KB
testcase_09 AC 355 ms
96,860 KB
testcase_10 AC 356 ms
96,724 KB
testcase_11 AC 266 ms
74,596 KB
testcase_12 AC 254 ms
73,384 KB
testcase_13 AC 54 ms
22,656 KB
testcase_14 AC 145 ms
50,464 KB
testcase_15 AC 125 ms
37,816 KB
testcase_16 AC 54 ms
20,704 KB
testcase_17 AC 118 ms
38,764 KB
testcase_18 AC 119 ms
36,768 KB
testcase_19 AC 85 ms
30,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static int NN => int.Parse(ReadLine());
    static long[] NList => ReadLine().Split().Select(long.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var mod = 998_244_353;
        var dp = new long[n + 1][];
        for (var i = 0; i < dp.Length; ++i) dp[i] = new long[n + 1];
        dp[0][0] = 1;
        for (var i = 0; i < n; ++i) for (var j = 0; j < n; ++j)
        {
            dp[i][j + 1] = (dp[i][j + 1] + dp[i][j] * 25) % mod;
            dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % mod;
        }
        var ans = 0L;
        for (var i = 3; i <= n; ++i)
        {
            ans = (ans + dp[i][n] * (i / 3)) % mod;
        }
        WriteLine(ans);
    }
}
0