結果

問題 No.2131 Concon Substrings (COuNt Version)
ユーザー 👑 chro_96chro_96
提出日時 2022-11-25 21:48:32
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 737 bytes
コンパイル時間 745 ms
コンパイル使用メモリ 30,848 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-10 03:01:19
合計ジャッジ時間 1,131 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 1 ms
6,944 KB
testcase_17 AC 1 ms
6,944 KB
testcase_18 AC 1 ms
6,940 KB
testcase_19 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main () {
  int n = 0;
  
  int res = 0;
  
  long long ans = 0LL;
  long long mod_num = 998244353LL;
  
  long long dp[3001][3] = {};
  long long pow26[3000] = {};
  
  res = scanf("%d", &n);
  
  pow26[0] = 1LL;
  for (int i = 1; i < n; i++) {
    pow26[i] = (pow26[i-1]*26LL)%mod_num;
  }
  
  dp[0][0] = 1LL;
  for (int i = 0; i < n; i++) {
    dp[i+1][0] = (dp[i][0]*25LL)%mod_num;
    dp[i+1][1] = (dp[i][1]*25LL)%mod_num;
    dp[i+1][2] = (dp[i][2]*25LL)%mod_num;
    dp[i+1][0] = (dp[i+1][0]+dp[i][2])%mod_num;
    dp[i+1][1] = (dp[i+1][1]+dp[i][0])%mod_num;
    dp[i+1][2] = (dp[i+1][2]+dp[i][1])%mod_num;
    ans += (dp[i][2]*pow26[n-i-1])%mod_num;
  }
  
  printf("%lld\n", ans%mod_num);
  return 0;
}
0