結果
問題 | No.251 大きな桁の復習問題(1) |
ユーザー | mits58 |
提出日時 | 2016-07-25 19:35:18 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 685 bytes |
コンパイル時間 | 2,887 ms |
コンパイル使用メモリ | 74,484 KB |
実行使用メモリ | 44,800 KB |
最終ジャッジ日時 | 2024-04-24 09:00:39 |
合計ジャッジ時間 | 11,189 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 102 ms
40,432 KB |
testcase_01 | AC | 105 ms
40,900 KB |
testcase_02 | AC | 110 ms
41,372 KB |
testcase_03 | AC | 110 ms
41,316 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 610 ms
44,800 KB |
testcase_10 | AC | 604 ms
44,632 KB |
testcase_11 | AC | 612 ms
44,556 KB |
testcase_12 | AC | 612 ms
44,576 KB |
testcase_13 | AC | 627 ms
44,632 KB |
testcase_14 | AC | 618 ms
44,644 KB |
testcase_15 | AC | 620 ms
44,724 KB |
testcase_16 | AC | 634 ms
44,796 KB |
testcase_17 | AC | 646 ms
44,628 KB |
testcase_18 | AC | 623 ms
44,636 KB |
testcase_19 | AC | 621 ms
44,756 KB |
testcase_20 | WA | - |
testcase_21 | AC | 105 ms
40,696 KB |
testcase_22 | AC | 108 ms
41,744 KB |
testcase_23 | AC | 107 ms
41,016 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 1; else if(a==0) return 1; 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())); } } }