結果

問題 No.251 大きな桁の復習問題(1)
ユーザー mits58mits58
提出日時 2016-07-25 19:34:11
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 651 bytes
コンパイル時間 2,315 ms
コンパイル使用メモリ 74,916 KB
実行使用メモリ 44,868 KB
最終ジャッジ日時 2024-04-24 08:58:47
合計ジャッジ時間 13,010 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
41,676 KB
testcase_01 WA -
testcase_02 AC 131 ms
41,316 KB
testcase_03 AC 132 ms
41,108 KB
testcase_04 AC 130 ms
41,328 KB
testcase_05 AC 133 ms
41,540 KB
testcase_06 AC 136 ms
41,836 KB
testcase_07 AC 134 ms
41,340 KB
testcase_08 AC 132 ms
41,444 KB
testcase_09 AC 706 ms
44,584 KB
testcase_10 AC 717 ms
44,784 KB
testcase_11 AC 726 ms
44,796 KB
testcase_12 AC 717 ms
44,492 KB
testcase_13 AC 726 ms
44,676 KB
testcase_14 AC 706 ms
44,868 KB
testcase_15 AC 706 ms
44,676 KB
testcase_16 AC 720 ms
44,472 KB
testcase_17 AC 721 ms
44,692 KB
testcase_18 AC 720 ms
44,516 KB
testcase_19 AC 711 ms
44,676 KB
testcase_20 AC 135 ms
41,220 KB
testcase_21 AC 119 ms
39,944 KB
testcase_22 AC 135 ms
41,384 KB
testcase_23 AC 132 ms
41,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.BigInteger;
import java.util.Scanner;

public class Main{
	static BigInteger mod=BigInteger.valueOf(129402307);
	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()){
			BigInteger n=sc.nextBigInteger();
			BigInteger m=sc.nextBigInteger();
			n=n.remainder(mod); m=m.remainder(mod.subtract(BigInteger.ONE));
			long nn=n.longValue(),mm=m.longValue();
			System.out.println(pow(nn,mm,mod.longValue()));
		}
	}
}
0