結果

問題 No.2752 文字列の数え上げ mod 998244353
ユーザー KeiKei
提出日時 2024-05-10 23:59:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 561 bytes
コンパイル時間 1,035 ms
コンパイル使用メモリ 87,328 KB
実行使用メモリ 159,392 KB
最終ジャッジ日時 2024-05-10 23:59:36
合計ジャッジ時間 5,614 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<map>
#include<atcoder/modint>
using namespace std;
using namespace atcoder;
using mint = atcoder::modint998244353;
const int MOD = 998244353;
map<long long, mint> mf;
mint f(long long L) {
  if (mf.count(L)) return mf[L];
  if (L == 0) return 0;
  if (L == 1) return 26;
  if (L % 2 == 1) {
    return mf[L] = (26 + 26 * f(L - 1));
  }
  return mf[L] = f(L / 2) + mint(26).pow(L / 2) * f(L / 2);
}
int main() {
  int T;
  cin >> T;
  while (T--) {
    long long L;
    cin >> L;
    cout << f(L).val() << endl;
  }
}
0