結果
問題 |
No.251 大きな桁の復習問題(1)
|
ユーザー |
![]() |
提出日時 | 2016-07-25 19:37:38 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 659 bytes |
コンパイル時間 | 3,049 ms |
コンパイル使用メモリ | 80,172 KB |
実行使用メモリ | 57,236 KB |
最終ジャッジ日時 | 2024-11-06 16:26:19 |
合計ジャッジ時間 | 12,952 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 WA * 2 |
ソースコード
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 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())); } } }