結果

問題 No.403 2^2^2
ユーザー ぴろずぴろず
提出日時 2016-07-22 23:14:07
言語 Java21
(openjdk 21)
結果
AC  
実行時間 165 ms / 2,000 ms
コード長 660 bytes
コンパイル時間 2,401 ms
コンパイル使用メモリ 77,176 KB
実行使用メモリ 42,784 KB
最終ジャッジ日時 2024-04-24 07:56:47
合計ジャッジ時間 8,324 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 163 ms
42,516 KB
testcase_01 AC 164 ms
42,640 KB
testcase_02 AC 160 ms
42,392 KB
testcase_03 AC 160 ms
42,716 KB
testcase_04 AC 161 ms
42,608 KB
testcase_05 AC 163 ms
42,636 KB
testcase_06 AC 161 ms
42,656 KB
testcase_07 AC 162 ms
42,588 KB
testcase_08 AC 163 ms
42,600 KB
testcase_09 AC 159 ms
42,616 KB
testcase_10 AC 161 ms
42,584 KB
testcase_11 AC 160 ms
42,592 KB
testcase_12 AC 162 ms
42,660 KB
testcase_13 AC 160 ms
42,288 KB
testcase_14 AC 165 ms
42,368 KB
testcase_15 AC 158 ms
42,380 KB
testcase_16 AC 158 ms
42,464 KB
testcase_17 AC 160 ms
42,508 KB
testcase_18 AC 160 ms
42,464 KB
testcase_19 AC 160 ms
42,676 KB
testcase_20 AC 162 ms
42,620 KB
testcase_21 AC 163 ms
42,744 KB
testcase_22 AC 162 ms
42,408 KB
testcase_23 AC 161 ms
42,476 KB
testcase_24 AC 165 ms
42,552 KB
testcase_25 AC 159 ms
42,520 KB
testcase_26 AC 161 ms
42,512 KB
testcase_27 AC 162 ms
42,784 KB
testcase_28 AC 162 ms
42,576 KB
testcase_29 AC 156 ms
42,408 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