結果

問題 No.2131 Concon Substrings (COuNt Version)
ユーザー simansiman
提出日時 2022-11-26 14:36:50
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 771 bytes
コンパイル時間 1,107 ms
コンパイル使用メモリ 141,772 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-10 15:37:35
合計ジャッジ時間 1,930 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

const ll MOD = 998244353;

int main() {
  int N;
  cin >> N;

  ll dp[N + 1];
  memset(dp, 0, sizeof(dp));
  dp[0] = 1;

  for (int i = 0; i < N; ++i) {
    for (int j = N; j >= 0; --j) {
      if (j < N) {
        dp[j + 1] += dp[j];
        dp[j + 1] %= MOD;
      }

      dp[j] *= 25;
      dp[j] %= MOD;
    }
  }

  ll ans = 0;

  for (int i = 0; i <= N; ++i) {
    ll cnt = i / 3;
    // fprintf(stderr, "i: %d, cnt: %lld\n", i, dp[i]);
    ans += cnt * dp[i];
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;
}
0