結果
| 問題 |
No.2752 文字列の数え上げ mod 998244353
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-10 22:30:08 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 254 ms / 2,000 ms |
| コード長 | 563 bytes |
| コンパイル時間 | 2,219 ms |
| コンパイル使用メモリ | 192,580 KB |
| 最終ジャッジ日時 | 2025-02-21 12:59:21 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const long mod = 998244353L;
/* mod 998244353における25の逆数 */
const long inv25 = 319438193L;
/* 26^L mod 998244353を求める */
long modpow(long L){
long a=26L;
long res=1L;
long e=L;
while(e){
if(e&1){
res=(res*a)%mod;
}
a=(a*a)%mod;
e>>=1;
}
return res;
}
/*
* 解:26*(26^L-1)/25
*/
int main(void){
int T;
cin >> T;
for(int t=0;t<T;t++){
long L;
cin >> L;
long res=(modpow(L)+mod-1)%mod;
res=(res*26)%mod;
res=(res*inv25)%mod;
cout << res << endl;
}
return 0;
}