結果

問題 No.403 2^2^2
ユーザー 37zigen37zigen
提出日時 2016-07-23 12:47:41
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 775 bytes
コンパイル時間 2,200 ms
コンパイル使用メモリ 80,584 KB
実行使用メモリ 42,656 KB
最終ジャッジ日時 2024-04-24 07:38:25
合計ジャッジ時間 7,442 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
41,952 KB
testcase_01 AC 141 ms
42,296 KB
testcase_02 AC 142 ms
42,336 KB
testcase_03 AC 138 ms
42,244 KB
testcase_04 AC 135 ms
42,140 KB
testcase_05 AC 137 ms
42,240 KB
testcase_06 AC 141 ms
42,368 KB
testcase_07 AC 140 ms
42,352 KB
testcase_08 AC 127 ms
42,188 KB
testcase_09 AC 136 ms
42,016 KB
testcase_10 AC 131 ms
41,808 KB
testcase_11 AC 151 ms
42,284 KB
testcase_12 AC 146 ms
42,432 KB
testcase_13 AC 128 ms
41,812 KB
testcase_14 AC 139 ms
42,224 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 142 ms
41,904 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 139 ms
42,108 KB
testcase_23 AC 135 ms
41,932 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 143 ms
42,272 KB
testcase_27 AC 132 ms
42,104 KB
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

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]);

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

	static long pow(long a, long n, long mod) {
		long A = a;
		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