結果

問題 No.1206 OR, OR, OR......
ユーザー ks2mks2m
提出日時 2020-08-30 13:15:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 825 bytes
コンパイル時間 2,448 ms
コンパイル使用メモリ 77,352 KB
実行使用メモリ 50,356 KB
最終ジャッジ日時 2024-04-27 06:46:57
合計ジャッジ時間 3,288 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
50,256 KB
testcase_01 AC 60 ms
50,132 KB
testcase_02 AC 60 ms
50,120 KB
testcase_03 AC 61 ms
50,356 KB
testcase_04 AC 60 ms
50,324 KB
testcase_05 AC 61 ms
50,004 KB
testcase_06 AC 62 ms
49,860 KB
testcase_07 AC 56 ms
49,976 KB
testcase_08 AC 57 ms
50,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine());
		int m = 998244353;
		for (int i = 0; i < t; i++) {
			String[] sa = br.readLine().split(" ");
			int n = Integer.parseInt(sa[0]);
			int k = Integer.parseInt(sa[1]);
			long total = power(power(2, n, m), k, m) * n % m;
			long rem = power(power(2, n - 1, m), k, m) * n % m;
			long ans = (total - rem + m) % m;
			System.out.println(ans);
		}
		br.close();
	}

	static long power(long x, long n, int m) {
		if (n == 0) {
			return 1;
		}
		long val = power(x, n / 2, m);
		val = val * val % m;
		if (n % 2 == 1) {
			val = val * x % m;
		}
		return val;
	}
}
0