結果
問題 |
No.2752 文字列の数え上げ mod 998244353
|
ユーザー |
|
提出日時 | 2024-05-10 23:32:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 83 ms / 2,000 ms |
コード長 | 759 bytes |
コンパイル時間 | 1,784 ms |
コンパイル使用メモリ | 192,164 KB |
最終ジャッジ日時 | 2025-02-21 13:22:07 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} const ll MOD=998244353; const ll inv5=319438193; ll power(ll x,ll r){ ll re=1,k=x; for(int i=0;i<60;i++){ if(r>>i&1){ re=(re*k)%MOD; } k=k*k%MOD; } return re; } void solve(){ ll L; cin>>L; ll ans=(power(26,L+1)-1)*inv5%MOD; ans--; if(ans<0)ans+=MOD; cout<<ans<<"\n"; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin>>T; while(T--){ solve(); } }