結果
問題 | No.251 大きな桁の復習問題(1) |
ユーザー | tenten |
提出日時 | 2021-11-10 21:07:28 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 154 ms / 5,000 ms |
コード長 | 1,668 bytes |
コンパイル時間 | 1,784 ms |
コンパイル使用メモリ | 77,804 KB |
実行使用メモリ | 53,152 KB |
最終ジャッジ日時 | 2024-05-01 09:38:51 |
合計ジャッジ時間 | 4,943 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 47 ms
49,996 KB |
testcase_01 | AC | 49 ms
50,296 KB |
testcase_02 | AC | 48 ms
50,208 KB |
testcase_03 | AC | 47 ms
50,364 KB |
testcase_04 | AC | 47 ms
50,316 KB |
testcase_05 | AC | 46 ms
49,896 KB |
testcase_06 | AC | 47 ms
50,232 KB |
testcase_07 | AC | 47 ms
50,256 KB |
testcase_08 | AC | 48 ms
50,132 KB |
testcase_09 | AC | 150 ms
52,304 KB |
testcase_10 | AC | 143 ms
52,308 KB |
testcase_11 | AC | 148 ms
52,436 KB |
testcase_12 | AC | 143 ms
52,984 KB |
testcase_13 | AC | 150 ms
52,540 KB |
testcase_14 | AC | 148 ms
53,080 KB |
testcase_15 | AC | 146 ms
52,616 KB |
testcase_16 | AC | 147 ms
52,452 KB |
testcase_17 | AC | 150 ms
52,296 KB |
testcase_18 | AC | 150 ms
53,152 KB |
testcase_19 | AC | 154 ms
52,832 KB |
testcase_20 | AC | 51 ms
50,300 KB |
testcase_21 | AC | 47 ms
50,296 KB |
testcase_22 | AC | 46 ms
50,284 KB |
testcase_23 | AC | 47 ms
50,164 KB |
ソースコード
import java.util.*; import java.io.*; public class Main { static final int MOD = 129402307; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); long base = 0; for (char c : sc.next().toCharArray()) { base *= 10; base += c - '0'; base %= MOD; } long next = base; long ans = 1; char[] arr = sc.next().toCharArray(); for (int i = arr.length - 1; i >= 0; i--) { ans *= pow(next, arr[i] - '0'); ans %= MOD; next = pow(next, 10); } System.out.println(ans); } static long pow(long x, int p) { if (p == 0) { return 1; } else if (p % 2 == 0) { return pow(x * x % MOD, p / 2); } else { return pow(x, p - 1) * x % MOD; } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String nextLine() throws Exception { return br.readLine(); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }