結果
| 問題 | 
                            No.2131 Concon Substrings (COuNt Version)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             umezo
                         | 
                    
| 提出日時 | 2022-11-25 22:20:06 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 63 ms / 2,000 ms | 
| コード長 | 778 bytes | 
| コンパイル時間 | 1,808 ms | 
| コンパイル使用メモリ | 193,180 KB | 
| 最終ジャッジ日時 | 2025-02-09 00:23:52 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 16 | 
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;
const int MOD=998244353;
ll dp[3030][1010][3];
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n;
  cin>>n;
  dp[0][0][0]=1;
  for(int i=0;i<n;i++){
    for(int j=0;j*3<=i;j++){
      dp[i+1][j][0]=(dp[i+1][j][0]+dp[i][j][0]*25%MOD)%MOD;
      dp[i+1][j][1]=(dp[i+1][j][1]+dp[i][j][0]+dp[i][j][1]*25%MOD)%MOD;
      dp[i+1][j][2]=(dp[i+1][j][2]+dp[i][j][1]+dp[i][j][2]*25%MOD)%MOD;
      dp[i+1][j+1][0]=(dp[i+1][j+1][0]+dp[i][j][2])%MOD;
    }
  }
  ll ans=0;
  for(int j=1;j<=1000;j++){
    for(int k=0;k<3;k++){
      ans=(ans+dp[n][j][k]*j%MOD)%MOD;
    }
  }
  cout<<ans<<endl;
  
  return 0;
}
            
            
            
        
            
umezo