結果

問題 No.403 2^2^2
ユーザー 37zigen37zigen
提出日時 2016-07-23 13:11:59
言語 Java21
(openjdk 21)
結果
AC  
実行時間 151 ms / 2,000 ms
コード長 886 bytes
コンパイル時間 3,453 ms
コンパイル使用メモリ 75,624 KB
実行使用メモリ 57,156 KB
最終ジャッジ日時 2023-08-06 12:27:47
合計ジャッジ時間 7,912 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 142 ms
54,544 KB
testcase_01 AC 143 ms
56,596 KB
testcase_02 AC 142 ms
56,820 KB
testcase_03 AC 145 ms
56,996 KB
testcase_04 AC 144 ms
56,764 KB
testcase_05 AC 145 ms
56,992 KB
testcase_06 AC 145 ms
56,676 KB
testcase_07 AC 147 ms
56,804 KB
testcase_08 AC 148 ms
56,756 KB
testcase_09 AC 146 ms
57,132 KB
testcase_10 AC 150 ms
56,848 KB
testcase_11 AC 150 ms
56,756 KB
testcase_12 AC 150 ms
56,852 KB
testcase_13 AC 120 ms
55,888 KB
testcase_14 AC 151 ms
56,844 KB
testcase_15 AC 116 ms
56,092 KB
testcase_16 AC 115 ms
55,712 KB
testcase_17 AC 144 ms
56,920 KB
testcase_18 AC 143 ms
56,860 KB
testcase_19 AC 142 ms
57,156 KB
testcase_20 AC 144 ms
57,108 KB
testcase_21 AC 145 ms
56,768 KB
testcase_22 AC 144 ms
56,780 KB
testcase_23 AC 145 ms
56,940 KB
testcase_24 AC 145 ms
56,676 KB
testcase_25 AC 117 ms
55,648 KB
testcase_26 AC 146 ms
56,936 KB
testcase_27 AC 145 ms
56,840 KB
testcase_28 AC 144 ms
56,868 KB
testcase_29 AC 116 ms
55,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package No400番台;

import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		solver();
	}

	static long MOD = 1_000_000_000 + 7;

	static void solver() {
		Scanner sc = new Scanner(System.in);
		String[] s = sc.next().split("\\^");

		long a = Long.parseLong(s[0]);
		long b = Long.parseLong(s[1]);
		long c = Long.parseLong(s[2]);

		if (a % MOD == 0) {
			System.out.println(0 + " " + 0);
			return;
		}
		System.out.println(
				pow(a, (b % (MOD - 1)) * (c % (MOD - 1)) % (MOD - 1), MOD) + " " + pow(a, pow(b, c, MOD - 1), MOD));
	}

	static long pow(long a, long n, long mod) {
		long A = a % mod;
		long ans = 1;
		for (; n >= 1; n >>= 1, A *= A, A %= mod) {
			if ((n & 1) == 1) {
				ans *= A;
				ans %= mod;
			}
		}
		return ans;
	}

	static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}
0