結果

問題 No.403 2^2^2
ユーザー mits58mits58
提出日時 2016-07-25 19:29:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 151 ms / 2,000 ms
コード長 627 bytes
コンパイル時間 3,711 ms
コンパイル使用メモリ 76,024 KB
実行使用メモリ 57,044 KB
最終ジャッジ日時 2023-08-06 13:16:48
合計ジャッジ時間 8,845 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 144 ms
56,960 KB
testcase_01 AC 146 ms
56,784 KB
testcase_02 AC 147 ms
56,764 KB
testcase_03 AC 146 ms
56,876 KB
testcase_04 AC 145 ms
56,548 KB
testcase_05 AC 144 ms
56,596 KB
testcase_06 AC 145 ms
56,552 KB
testcase_07 AC 144 ms
57,016 KB
testcase_08 AC 146 ms
56,796 KB
testcase_09 AC 149 ms
56,964 KB
testcase_10 AC 144 ms
56,856 KB
testcase_11 AC 144 ms
56,868 KB
testcase_12 AC 146 ms
56,880 KB
testcase_13 AC 149 ms
56,940 KB
testcase_14 AC 144 ms
56,604 KB
testcase_15 AC 144 ms
56,672 KB
testcase_16 AC 147 ms
56,816 KB
testcase_17 AC 144 ms
56,556 KB
testcase_18 AC 146 ms
56,852 KB
testcase_19 AC 143 ms
56,536 KB
testcase_20 AC 147 ms
56,952 KB
testcase_21 AC 145 ms
56,548 KB
testcase_22 AC 151 ms
57,044 KB
testcase_23 AC 143 ms
56,508 KB
testcase_24 AC 144 ms
56,536 KB
testcase_25 AC 145 ms
56,564 KB
testcase_26 AC 145 ms
56,556 KB
testcase_27 AC 144 ms
56,760 KB
testcase_28 AC 144 ms
56,816 KB
testcase_29 AC 143 ms
54,716 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