結果

問題 No.251 大きな桁の復習問題(1)
コンテスト
ユーザー mits58
提出日時 2016-07-25 19:34:11
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
WA  
実行時間 -
コード長 651 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,730 ms
コンパイル使用メモリ 82,160 KB
実行使用メモリ 47,872 KB
最終ジャッジ日時 2026-05-06 21:01:21
合計ジャッジ時間 11,067 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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