結果

問題 No.251 大きな桁の復習問題(1)
ユーザー htensaihtensai
提出日時 2020-01-28 17:15:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 164 ms / 5,000 ms
コード長 1,139 bytes
コンパイル時間 3,133 ms
コンパイル使用メモリ 73,620 KB
実行使用メモリ 55,636 KB
最終ジャッジ日時 2023-10-13 17:54:25
合計ジャッジ時間 7,103 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
49,352 KB
testcase_01 AC 41 ms
49,040 KB
testcase_02 AC 39 ms
49,052 KB
testcase_03 AC 40 ms
49,272 KB
testcase_04 AC 40 ms
49,036 KB
testcase_05 AC 40 ms
49,484 KB
testcase_06 AC 41 ms
49,140 KB
testcase_07 AC 41 ms
49,140 KB
testcase_08 AC 43 ms
49,064 KB
testcase_09 AC 164 ms
55,388 KB
testcase_10 AC 130 ms
54,760 KB
testcase_11 AC 154 ms
55,268 KB
testcase_12 AC 132 ms
54,168 KB
testcase_13 AC 150 ms
55,128 KB
testcase_14 AC 142 ms
55,360 KB
testcase_15 AC 135 ms
55,168 KB
testcase_16 AC 125 ms
54,312 KB
testcase_17 AC 125 ms
55,636 KB
testcase_18 AC 134 ms
55,216 KB
testcase_19 AC 124 ms
54,556 KB
testcase_20 AC 40 ms
48,984 KB
testcase_21 AC 44 ms
49,000 KB
testcase_22 AC 41 ms
48,920 KB
testcase_23 AC 40 ms
49,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    static final int MOD = 129402307;
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        char[] nArr = br.readLine().toCharArray();
        char[] mArr = br.readLine().toCharArray();
        long n = 0;
        for (char c : nArr) {
            n *= 10;
            n += c - '0';
            n %= MOD;
        }
        int length = mArr.length;
        long[] values = new long[length];
        values[0] = n;
        for (int i = 1; i < length; i++) {
            values[i] = 1;
            for (int j = 0; j < 10; j++) {
                values[i] *= values[i - 1];
                values[i] %= MOD;
            }
        }
        long ans = 1;
        for (int i = 0; i < length; i++) {
            int x = mArr[length - 1 - i] - '0';
            long tmp = 1;
            for (int j = 0; j < x; j++) {
                tmp *= values[i];
                tmp %= MOD;
            }
            ans *= tmp;
            ans %= MOD;
        }
        System.out.println(ans);
  }
}
0