結果

問題 No.1800 Random XOR
ユーザー ks2mks2m
提出日時 2022-01-07 21:31:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 585 bytes
コンパイル時間 2,043 ms
コンパイル使用メモリ 74,084 KB
実行使用メモリ 41,776 KB
最終ジャッジ日時 2024-04-26 18:29:45
合計ジャッジ時間 4,888 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
41,776 KB
testcase_01 AC 128 ms
41,168 KB
testcase_02 AC 127 ms
41,092 KB
testcase_03 AC 126 ms
41,340 KB
testcase_04 AC 128 ms
41,500 KB
testcase_05 AC 127 ms
41,196 KB
testcase_06 AC 126 ms
40,984 KB
testcase_07 AC 129 ms
41,040 KB
testcase_08 AC 131 ms
41,256 KB
testcase_09 AC 130 ms
41,272 KB
testcase_10 AC 130 ms
41,776 KB
testcase_11 AC 132 ms
41,228 KB
testcase_12 AC 131 ms
41,388 KB
testcase_13 AC 131 ms
41,384 KB
testcase_14 AC 131 ms
40,984 KB
testcase_15 AC 131 ms
40,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		sc.close();

		int mod = 1000000007;
		m %= mod - 1;
		long a = power(2, m, mod) - 1;
		if (a < 0) {
			a += mod;
		}
		a *= 500000004;
		a %= mod;
		System.out.println(a);
	}

	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) {
			x %= m;
			val = val * x % m;
		}
		return val;
	}
}
0