結果

問題 No.403 2^2^2
ユーザー 37zigen37zigen
提出日時 2016-07-23 12:35:40
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 772 bytes
コンパイル時間 2,329 ms
コンパイル使用メモリ 82,544 KB
実行使用メモリ 42,776 KB
最終ジャッジ日時 2024-04-24 07:37:00
合計ジャッジ時間 7,274 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
41,660 KB
testcase_01 AC 122 ms
42,112 KB
testcase_02 AC 131 ms
41,900 KB
testcase_03 AC 127 ms
42,420 KB
testcase_04 AC 118 ms
41,896 KB
testcase_05 AC 127 ms
42,384 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 126 ms
41,724 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 120 ms
41,924 KB
testcase_14 WA -
testcase_15 AC 132 ms
42,160 KB
testcase_16 AC 120 ms
41,868 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 138 ms
42,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 134 ms
42,364 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]);

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

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