結果

問題 No.1206 OR, OR, OR......
ユーザー misora192misora192
提出日時 2020-11-01 22:01:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 985 bytes
コンパイル時間 2,711 ms
コンパイル使用メモリ 167,768 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 11:24:55
合計ジャッジ時間 2,520 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// mod calc
typedef long long ll;
const ll MOD = 998244353;;

ll powmod(ll a, ll b){
	if(b == 0) return 1;
	if(b & 1) {
		return a * powmod(a, b - 1) % MOD;
	} else {
		ll d = powmod(a, b / 2) % MOD;
		return d * d % MOD;
	}
}

ll sub(ll a, ll b){
	return a + MOD - b;
}

ll inv(ll a){
	return powmod(a, MOD - 2);
}

// X^(-1) = X^(p-2) (mod p) (Fermat's little theorem)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int t;
	cin >> t;

	vector<ll> n(t), k(t);
	rep(i, t) cin >> n[i] >> k[i];


	rep(i, t){
		ll ans = n[i];
		ans *= powmod(2ll, n[i] * k[i]);
		ans %= MOD;
		
		ll x = powmod(inv(2ll), k[i]);
		ans *= (1 + MOD - x) % MOD;
		ans %= MOD;

		cout << ans << endl;
	}
}
0