結果

問題 No.403 2^2^2
ユーザー ぴろずぴろず
提出日時 2016-07-22 23:14:07
言語 Java21
(openjdk 21)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 660 bytes
コンパイル時間 2,594 ms
コンパイル使用メモリ 75,656 KB
実行使用メモリ 57,264 KB
最終ジャッジ日時 2023-08-06 12:09:09
合計ジャッジ時間 8,930 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 159 ms
55,000 KB
testcase_01 AC 154 ms
56,752 KB
testcase_02 AC 158 ms
56,652 KB
testcase_03 AC 157 ms
56,776 KB
testcase_04 AC 155 ms
56,904 KB
testcase_05 AC 156 ms
57,040 KB
testcase_06 AC 154 ms
56,936 KB
testcase_07 AC 156 ms
56,660 KB
testcase_08 AC 160 ms
56,868 KB
testcase_09 AC 156 ms
56,492 KB
testcase_10 AC 153 ms
56,716 KB
testcase_11 AC 154 ms
56,940 KB
testcase_12 AC 156 ms
56,712 KB
testcase_13 AC 155 ms
56,684 KB
testcase_14 AC 158 ms
56,624 KB
testcase_15 AC 154 ms
56,480 KB
testcase_16 AC 154 ms
56,816 KB
testcase_17 AC 158 ms
56,972 KB
testcase_18 AC 155 ms
56,932 KB
testcase_19 AC 156 ms
57,264 KB
testcase_20 AC 156 ms
56,916 KB
testcase_21 AC 156 ms
56,628 KB
testcase_22 AC 154 ms
56,696 KB
testcase_23 AC 156 ms
56,900 KB
testcase_24 AC 160 ms
56,556 KB
testcase_25 AC 159 ms
56,932 KB
testcase_26 AC 157 ms
57,192 KB
testcase_27 AC 159 ms
56,908 KB
testcase_28 AC 157 ms
56,712 KB
testcase_29 AC 153 ms
56,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no403;

import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static BigInteger MOD = BigInteger.valueOf(1000000007);
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = sc.next().split("\\^");
		BigInteger a = new BigInteger(s[0]);
		BigInteger b = new BigInteger(s[1]);
		BigInteger c = new BigInteger(s[2]);
		BigInteger x = a.modPow(b, MOD).modPow(c, MOD);
		BigInteger y;
		if (a.mod(MOD).equals(BigInteger.ZERO)) { //0^0対策
			y = BigInteger.ZERO;
		}else{
			y = a.modPow(b.modPow(c, MOD.subtract(BigInteger.ONE)), MOD);
		}
		
		System.out.println(x + " " + y);
	}
}
0