結果
問題 | No.2752 文字列の数え上げ mod 998244353 |
ユーザー |
|
提出日時 | 2024-05-10 22:21:41 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 399 ms / 2,000 ms |
コード長 | 1,016 bytes |
コンパイル時間 | 2,258 ms |
コンパイル使用メモリ | 202,560 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-20 06:06:36 |
合計ジャッジ時間 | 5,458 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;using ull = unsigned long long;using Matrix = vector<vector<ll>>;const int inf = 1000000000;const ll INF = 1000000000000000000;const ll mod = 998244353;const ull mod_hash = (1UL << 61) - 1;const vector<int> dx = {0, 1, 0, -1, 1, 1, -1, -1};const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};ll extGCD(ll a, ll b, ll &x, ll &y) {if (b == 0) {x = 1;y = 0;return a;}ll d = extGCD(b, a % b, x, y);swap(x, y);y -= a / b * x;return d;}ll modinv(ll a, ll m) {ll x, y;extGCD(a, m, x, y);if (x < 0) x += m;return x % m;}ll modpow(ll a, ll n, ll m) {if (n == 0) return 1;if (n == 1) return a % m;if (n % 2 == 0) {ll t = modpow(a, n / 2, m);return (t * t) % m;} else {return modpow(a, n - 1, m) * a % m;}}int main(){int T;cin>>T;while(T--){ll l;cin>>l;cout<<26 * ((modpow(26, l, mod) - 1) + mod) % mod * modinv(25, mod) % mod<<endl;}return 0;}