結果

問題 No.2131 Concon Substrings (COuNt Version)
ユーザー Nzt3Nzt3
提出日時 2022-11-27 20:24:48
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 532 bytes
コンパイル時間 2,024 ms
コンパイル使用メモリ 199,276 KB
実行使用メモリ 73,728 KB
最終ジャッジ日時 2024-04-15 02:29:56
合計ジャッジ時間 3,136 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
void ch(long long &a,long long b){
  a=(a+b)%mod;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin>>N;
  vector<vector<long long>>dp(N,vector<long long>(N+1));
  dp[0][0]=25,dp[0][1]=1;
  for(int i=0;i<N-1;i++){
    for(int j=0;j<=N;j++){
      ch(dp[i+1][j],25ll*dp[i][j]);
      if(j!=N)ch(dp[i+1][j+1],dp[i][j]);
    }
  }


  long long ans=0;
  for(long long i=0;i<=N;i++){
    ch(ans,i/3*dp[N-1][i]);
  }
  cout<<ans<<'\n';
}
0