結果

問題 No.403 2^2^2
ユーザー TatsuDXTatsuDX
提出日時 2016-09-03 17:54:43
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 669 bytes
コンパイル時間 3,276 ms
コンパイル使用メモリ 78,872 KB
実行使用メモリ 55,088 KB
最終ジャッジ日時 2024-04-27 15:37:46
合計ジャッジ時間 8,517 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
54,640 KB
testcase_01 AC 138 ms
54,700 KB
testcase_02 AC 139 ms
54,700 KB
testcase_03 AC 138 ms
54,780 KB
testcase_04 AC 136 ms
55,068 KB
testcase_05 AC 128 ms
54,504 KB
testcase_06 AC 126 ms
54,380 KB
testcase_07 AC 130 ms
54,448 KB
testcase_08 AC 139 ms
55,088 KB
testcase_09 AC 131 ms
54,612 KB
testcase_10 AC 140 ms
54,660 KB
testcase_11 AC 140 ms
54,880 KB
testcase_12 AC 148 ms
54,632 KB
testcase_13 AC 137 ms
54,816 KB
testcase_14 AC 137 ms
54,784 KB
testcase_15 AC 129 ms
54,732 KB
testcase_16 AC 135 ms
54,536 KB
testcase_17 AC 137 ms
54,748 KB
testcase_18 WA -
testcase_19 AC 143 ms
54,816 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 143 ms
54,828 KB
testcase_23 AC 137 ms
54,624 KB
testcase_24 WA -
testcase_25 AC 142 ms
54,760 KB
testcase_26 AC 145 ms
54,812 KB
testcase_27 AC 144 ms
54,752 KB
testcase_28 AC 136 ms
54,828 KB
testcase_29 AC 138 ms
54,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Test {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String[] s = sc.nextLine().split("\\^");
		long a, b, c, tmp, x, y;
		a = Long.parseLong(s[0]) % e;
		b = Long.parseLong(s[1]) % (e-1);
		c = Long.parseLong(s[2]) % (e-1);

		x = p(a, (b*c)%(e-1), e);
		tmp = p(b, c, e-1);
		y = p(a, tmp, e);
		System.out.println(x + " " + y);
	}

	public static long e = 1000000007;
	public static long p(long a, long b, long m){
		if(a == 0){
			return 0;
		} else if(b == 0){
			return 1;
		}
		a %= m;
		if(b%2 == 0){
			return p(a*a, b/2, m)%m;
		} else {
			return (a * p(a*a, b/2, m))%m;
		}

	}
}
0