結果

問題 No.403 2^2^2
ユーザー 37zigen37zigen
提出日時 2016-07-23 12:53:57
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 866 bytes
コンパイル時間 2,170 ms
コンパイル使用メモリ 79,780 KB
実行使用メモリ 42,568 KB
最終ジャッジ日時 2024-04-24 07:39:30
合計ジャッジ時間 7,265 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
41,956 KB
testcase_01 AC 146 ms
42,292 KB
testcase_02 AC 133 ms
41,800 KB
testcase_03 AC 145 ms
41,840 KB
testcase_04 AC 139 ms
42,400 KB
testcase_05 AC 135 ms
42,068 KB
testcase_06 AC 145 ms
42,348 KB
testcase_07 AC 140 ms
41,956 KB
testcase_08 AC 144 ms
42,436 KB
testcase_09 AC 145 ms
42,244 KB
testcase_10 AC 124 ms
41,844 KB
testcase_11 AC 137 ms
42,348 KB
testcase_12 AC 133 ms
42,236 KB
testcase_13 AC 101 ms
40,188 KB
testcase_14 AC 130 ms
42,108 KB
testcase_15 AC 114 ms
40,084 KB
testcase_16 AC 120 ms
41,216 KB
testcase_17 AC 140 ms
42,152 KB
testcase_18 WA -
testcase_19 AC 156 ms
42,284 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 137 ms
41,956 KB
testcase_23 AC 156 ms
42,348 KB
testcase_24 WA -
testcase_25 AC 122 ms
41,096 KB
testcase_26 AC 135 ms
41,828 KB
testcase_27 AC 145 ms
42,568 KB
testcase_28 AC 143 ms
42,312 KB
testcase_29 AC 114 ms
40,872 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) + " " + 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