結果
問題 | No.251 大きな桁の復習問題(1) |
ユーザー | mits58 |
提出日時 | 2016-07-25 19:37:38 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 659 bytes |
コンパイル時間 | 4,380 ms |
コンパイル使用メモリ | 74,344 KB |
実行使用メモリ | 44,700 KB |
最終ジャッジ日時 | 2024-04-24 09:01:28 |
合計ジャッジ時間 | 12,731 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 134 ms
41,420 KB |
testcase_01 | AC | 135 ms
41,280 KB |
testcase_02 | AC | 120 ms
40,152 KB |
testcase_03 | AC | 133 ms
41,004 KB |
testcase_04 | WA | - |
testcase_05 | AC | 134 ms
41,516 KB |
testcase_06 | WA | - |
testcase_07 | AC | 136 ms
41,244 KB |
testcase_08 | AC | 134 ms
41,220 KB |
testcase_09 | AC | 706 ms
44,516 KB |
testcase_10 | AC | 714 ms
44,512 KB |
testcase_11 | AC | 726 ms
44,552 KB |
testcase_12 | AC | 722 ms
44,568 KB |
testcase_13 | AC | 709 ms
44,384 KB |
testcase_14 | AC | 709 ms
44,576 KB |
testcase_15 | AC | 723 ms
44,608 KB |
testcase_16 | AC | 716 ms
44,448 KB |
testcase_17 | AC | 720 ms
44,360 KB |
testcase_18 | AC | 721 ms
44,700 KB |
testcase_19 | AC | 713 ms
44,664 KB |
testcase_20 | AC | 138 ms
41,524 KB |
testcase_21 | AC | 135 ms
41,212 KB |
testcase_22 | AC | 132 ms
41,512 KB |
testcase_23 | AC | 132 ms
41,116 KB |
ソースコード
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())); } } }