結果

問題 No.2816 At Most Two Moves
ユーザー zeta7532
提出日時 2024-07-18 01:14:47
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 908 bytes
コンパイル時間 2,112 ms
コンパイル使用メモリ 197,364 KB
最終ジャッジ日時 2025-02-23 16:07:33
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
const ll mod = 998244353;
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define faster ios::sync_with_stdio(false);cin.tie(nullptr)

ll modpow(ll A,ll N){
    ll res=1;
    while(N){
        if(N&1) res=res*A%mod;
        A=A*A%mod;
        N>>=1;
    }
    return res;
}

ll modinv(ll A){return modpow(A,mod-2);}

ll solve(ll N){
    ll ans=0;
    ll M=N%(mod-1)+(mod-1);
    ans+=modpow(2,(M*(M-1))/2);
    ll cnt=(modpow(2,2*M-3)+mod-modpow(3,M-2))*modpow(2,(M*(M-1))/2+(mod-1)*5-(2*M-3));
    cnt%=mod;
    ans+=cnt*(N-1);
    return ans%mod;
}

int main() {
    ll T;
    cin >> T;
    while(T--){
        ll N;
        cin >> N;
        cout << solve(N) << endl;
    }
    return 0;
}
0