結果

問題 No.2131 Concon Substrings (COuNt Version)
ユーザー FplusFplusFFplusFplusF
提出日時 2022-11-25 22:23:19
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 834 bytes
コンパイル時間 2,513 ms
コンパイル使用メモリ 200,076 KB
実行使用メモリ 73,728 KB
最終ジャッジ日時 2024-04-10 03:34:00
合計ジャッジ時間 3,558 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 37 ms
35,200 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 79 ms
73,728 KB
testcase_08 AC 21 ms
20,864 KB
testcase_09 AC 79 ms
73,600 KB
testcase_10 AC 79 ms
73,472 KB
testcase_11 AC 55 ms
52,352 KB
testcase_12 AC 52 ms
49,664 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 24 ms
23,808 KB
testcase_15 AC 20 ms
19,840 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 18 ms
18,048 KB
testcase_18 AC 18 ms
18,304 KB
testcase_19 AC 10 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (long long i=0;i<(long long)(n);i++)
#define all(v) v.begin(),v.end()
using ll=long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
const ll INF=(1ll<<60);
template<class T> void chmin(T &a,T b){
    if(a>b){
        a=b;
    }
}
template<class T> void chmax(T &a,T b){
    if(a<b){
        a=b;
    }
}
int main(){
    const ll mod=998244353;
    ll n;
    cin >> n;
    vector<vector<ll>> dp(n+1,vector<ll>(n+1,0));
    dp[0][0]=1;
    rep(i,n){
        rep(j,n){
            if(dp[i][j]==0) continue;
            dp[i+1][j]+=25*dp[i][j];
            dp[i+1][j]%=mod;
            dp[i+1][j+1]+=dp[i][j];
            dp[i+1][j+1]%=mod;
        }
    }
    ll ans=0;
    rep(j,n+1){
        ans+=j/3*dp[n][j];
        ans%=mod;
    }
    cout << ans << endl;
}
0