Untitled
#pragma GCC optimize("O2,no-stack-protector,unroll-loops") #define ll long long #define pb push_back #define ipar(arr, n) vector<ll> arr(n); for(int i=0;i<n;i++) cin>>arr[i]; #include <cmath> #include <bits/stdc++.h> #define pii pair<int, int>; #define pll pair<ll, ll>; using namespace std; ll binpow(ll a,ll b,ll MOD){ ll ans=1; // Initialize the result to 1 a%=MOD; // Take the modulo of base 'a' with MOD while(b){ // Iterate until the exponent 'b' becomes zero if(b&1) // If the least significant bit of 'b' is set (i.e., 'b' is odd) ans=(ans*a)%MOD; // Update the result by multiplying 'ans' with 'a' and taking modulo b/=2; // Right-shift 'b' to discard the least significant bit a=(a*a)%MOD; // Square 'a' and take modulo } return ans; // Return the final result } void solve(){ const ll MOD=998244353; ll n,k;cin>>n>>k; ll res=binpow(2,n-1,MOD); res=binpow(res,k,MOD); //res=(res| (1<<k))%MOD; cout<<res<<"\n"; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); int t; cin>>t; while(t--) solve(); }
Leave a Comment