結果

問題 No.251 大きな桁の復習問題(1)
ユーザー mits58mits58
提出日時 2016-07-25 19:42:05
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 704 bytes
コンパイル時間 2,157 ms
コンパイル使用メモリ 74,388 KB
実行使用メモリ 44,692 KB
最終ジャッジ日時 2024-04-24 09:03:37
合計ジャッジ時間 13,473 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
41,196 KB
testcase_01 WA -
testcase_02 AC 135 ms
41,156 KB
testcase_03 AC 132 ms
41,480 KB
testcase_04 AC 136 ms
41,460 KB
testcase_05 AC 132 ms
41,268 KB
testcase_06 AC 133 ms
41,408 KB
testcase_07 AC 136 ms
41,536 KB
testcase_08 AC 132 ms
41,016 KB
testcase_09 AC 715 ms
44,560 KB
testcase_10 AC 704 ms
44,400 KB
testcase_11 AC 741 ms
44,604 KB
testcase_12 AC 758 ms
44,468 KB
testcase_13 AC 719 ms
44,592 KB
testcase_14 AC 725 ms
44,664 KB
testcase_15 AC 717 ms
44,692 KB
testcase_16 AC 715 ms
44,684 KB
testcase_17 AC 710 ms
44,596 KB
testcase_18 AC 716 ms
44,228 KB
testcase_19 AC 723 ms
44,408 KB
testcase_20 AC 135 ms
41,120 KB
testcase_21 AC 133 ms
41,168 KB
testcase_22 AC 134 ms
41,320 KB
testcase_23 AC 134 ms
41,516 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 && x==0) return 1;
		else if(a==0 && x!=0) return 0;
		else if(a==0 && x==0) return 0;
		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