結果

問題 No.1206 OR, OR, OR......
ユーザー startcppstartcpp
提出日時 2020-08-30 17:18:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 543 bytes
コンパイル時間 711 ms
コンパイル使用メモリ 65,784 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-09 16:58:28
合計ジャッジ時間 1,450 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#define int long long
using namespace std;

int powmod(int a, int n, int mod) {
	if (n == 0) return 1;
	if (n % 2 == 0) return powmod((a * a) % mod, n / 2, mod);
	return (a * powmod(a, n - 1, mod)) % mod;
}

int mod = 998244353;

signed main() {
	int t; cin >> t;
	while (t--) {
		int n, k;
		cin >> n >> k;
		
		//n (2^(nk) - 2^((n-1)k))
		int res1 = powmod(2, n * k, mod);
		int res2 = powmod(2, (n - 1) * k, mod);
		int res3 = (res1 - res2 + mod) % mod;
		int ans = n * res3 % mod;
		cout << ans << endl;
	}
	return 0;
}
0