結果

問題 No.403 2^2^2
ユーザー mits58mits58
提出日時 2016-07-25 19:29:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 627 bytes
コンパイル時間 2,081 ms
コンパイル使用メモリ 79,376 KB
実行使用メモリ 42,608 KB
最終ジャッジ日時 2024-04-24 08:57:56
合計ジャッジ時間 6,734 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
41,736 KB
testcase_01 AC 114 ms
42,060 KB
testcase_02 AC 126 ms
42,032 KB
testcase_03 AC 127 ms
42,608 KB
testcase_04 AC 121 ms
41,988 KB
testcase_05 AC 117 ms
42,092 KB
testcase_06 AC 116 ms
41,860 KB
testcase_07 AC 128 ms
42,188 KB
testcase_08 AC 132 ms
42,244 KB
testcase_09 AC 128 ms
42,444 KB
testcase_10 AC 131 ms
42,160 KB
testcase_11 AC 132 ms
42,036 KB
testcase_12 AC 125 ms
41,788 KB
testcase_13 AC 125 ms
42,408 KB
testcase_14 AC 118 ms
42,076 KB
testcase_15 AC 129 ms
42,304 KB
testcase_16 AC 122 ms
41,948 KB
testcase_17 AC 135 ms
41,940 KB
testcase_18 AC 116 ms
42,240 KB
testcase_19 AC 132 ms
42,072 KB
testcase_20 AC 117 ms
42,120 KB
testcase_21 AC 126 ms
42,136 KB
testcase_22 AC 128 ms
42,304 KB
testcase_23 AC 124 ms
41,792 KB
testcase_24 AC 121 ms
41,852 KB
testcase_25 AC 122 ms
42,248 KB
testcase_26 AC 122 ms
42,004 KB
testcase_27 AC 134 ms
42,352 KB
testcase_28 AC 119 ms
42,044 KB
testcase_29 AC 130 ms
42,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main{
	static long mod=1000000007;
	static long pow(long a,long x,long m){
		if(a==0) return 0;
		else if(x==0) return 1;
		else if(x%2==0) return pow((a*a)%m,x/2,m)%m;
		else return (a*pow((a*a)%m,x/2,m))%m;
	}
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			String[] str=(sc.next()).split("\\^");
			long a=Long.valueOf(str[0])%mod,b=Long.valueOf(str[1]),c=Long.valueOf(str[2]);
			long ab=pow(a%mod,b,mod); ab=pow(ab%mod,c,mod);
			long bc=pow(b%(mod-1),c,mod-1); bc=pow(a%mod,bc,mod);
			System.out.println(ab+" "+bc);
		}
	}
}
0