結果
| 問題 |
No.2752 文字列の数え上げ mod 998244353
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-10 23:59:30 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 561 bytes |
| コンパイル時間 | 708 ms |
| コンパイル使用メモリ | 82,932 KB |
| 最終ジャッジ日時 | 2025-02-21 13:25:29 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 TLE * 1 -- * 4 |
ソースコード
#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;
}
}