結果

問題 No.2131 Concon Substrings (COuNt Version)
ユーザー 👑 AngrySadEight
提出日時 2022-10-25 00:02:54
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 247 ms / 2,000 ms
コード長 562 bytes
コンパイル時間 750 ms
コンパイル使用メモリ 74,816 KB
最終ジャッジ日時 2025-02-08 12:28:18
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

ll mod = 998244353;

int main(){
    ll N;
    cin >> N;
    vector<vector<ll>> dp(N + 1, vector<ll>(N + 2, 0));
    dp[0][0] = 1;
    for (ll i = 0; i < N; i++){
        for (ll j = 0; j <= N; j++){
            dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % mod;
            dp[i + 1][j] = (dp[i + 1][j] + dp[i][j] * 25LL) % mod;
        }
    }
    ll ans = 0;
    for (ll j = 0; j <= N; j++){
        ans = (ans + dp[N][j] * (j / 3)) % mod;
    }
    cout << ans << endl;
}
0