結果
問題 |
No.2752 文字列の数え上げ mod 998244353
|
ユーザー |
|
提出日時 | 2024-05-10 23:54:29 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 560 bytes |
コンパイル時間 | 779 ms |
コンパイル使用メモリ | 82,524 KB |
最終ジャッジ日時 | 2025-02-21 13:24:43 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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[L] != 0) 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; } }