結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
42,072 KB
testcase_01 AC 129 ms
42,284 KB
testcase_02 AC 126 ms
42,032 KB
testcase_03 AC 133 ms
42,348 KB
testcase_04 AC 131 ms
42,528 KB
testcase_05 AC 118 ms
42,084 KB
testcase_06 AC 128 ms
42,456 KB
testcase_07 AC 129 ms
42,488 KB
testcase_08 AC 123 ms
41,980 KB
testcase_09 AC 121 ms
42,064 KB
testcase_10 AC 137 ms
41,956 KB
testcase_11 AC 121 ms
42,044 KB
testcase_12 AC 130 ms
42,456 KB
testcase_13 AC 129 ms
42,128 KB
testcase_14 AC 132 ms
42,324 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 128 ms
42,368 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 123 ms
41,844 KB
testcase_23 AC 134 ms
42,088 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 122 ms
41,724 KB
testcase_27 AC 131 ms
42,368 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 %(MOD-1)* 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