結果
問題 | No.2131 Concon Substrings (COuNt Version) |
ユーザー |
![]() |
提出日時 | 2022-11-25 22:23:19 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 79 ms / 2,000 ms |
コード長 | 834 bytes |
コンパイル時間 | 2,034 ms |
コンパイル使用メモリ | 198,544 KB |
最終ジャッジ日時 | 2025-02-09 00:26:06 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
ソースコード
#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; }