結果

問題 No.2752 文字列の数え上げ mod 998244353
ユーザー hiromi_ayase
提出日時 2024-05-10 21:44:07
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 198 ms / 2,000 ms
コード長 667 bytes
コンパイル時間 5,335 ms
コンパイル使用メモリ 309,348 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-20 04:52:27
合計ジャッジ時間 7,203 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/all>
using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
#define FAST_IO                \
  ios::sync_with_stdio(false); \
  cin.tie(0);
const i64 INF = 1001001001001001001;
using Modint = atcoder::static_modint<998244353>;

void solve(i64 L) {
  Modint x = 26;
  // ans = x^1 + x^2 + ... + x^L
  //    = (x^(L + 1) - 1) / (x - 1)

  Modint ans = (x.pow(L + 1) - 1) / (x - 1) - 1;
  cout << ans.val() << endl;
}

int main() {
  FAST_IO
  auto ans = 0LL;

  int T;
  cin >> T;

  for (int i = 0; i < T; i ++) {
    i64 L;
    cin >> L;
    solve(L);
  }

}
0