結果

問題 No.167 N^M mod 10
ユーザー htensaihtensai
提出日時 2019-12-18 08:29:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 48 ms / 1,000 ms
コード長 1,471 bytes
コンパイル時間 2,939 ms
コンパイル使用メモリ 74,072 KB
実行使用メモリ 49,596 KB
最終ジャッジ日時 2023-09-19 07:16:22
合計ジャッジ時間 5,802 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
48,924 KB
testcase_01 AC 43 ms
49,448 KB
testcase_02 AC 45 ms
49,568 KB
testcase_03 AC 45 ms
49,152 KB
testcase_04 AC 45 ms
49,300 KB
testcase_05 AC 43 ms
49,236 KB
testcase_06 AC 43 ms
49,272 KB
testcase_07 AC 44 ms
49,244 KB
testcase_08 AC 44 ms
49,312 KB
testcase_09 AC 44 ms
49,316 KB
testcase_10 AC 44 ms
48,932 KB
testcase_11 AC 44 ms
48,932 KB
testcase_12 AC 45 ms
49,100 KB
testcase_13 AC 45 ms
49,240 KB
testcase_14 AC 45 ms
49,312 KB
testcase_15 AC 45 ms
49,152 KB
testcase_16 AC 45 ms
49,308 KB
testcase_17 AC 46 ms
49,192 KB
testcase_18 AC 45 ms
48,948 KB
testcase_19 AC 46 ms
49,140 KB
testcase_20 AC 45 ms
49,424 KB
testcase_21 AC 45 ms
48,924 KB
testcase_22 AC 48 ms
49,312 KB
testcase_23 AC 48 ms
49,208 KB
testcase_24 AC 48 ms
49,168 KB
testcase_25 AC 47 ms
49,140 KB
testcase_26 AC 47 ms
49,228 KB
testcase_27 AC 47 ms
49,596 KB
testcase_28 AC 48 ms
49,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String first = br.readLine();
        int n = first.charAt(first.length() - 1) - '0';
        String second = br.readLine();
        int m;
        if (second.length() == 1) {
            m = second.charAt(0) - '0';
            if (m == 0) {
                System.out.println(1);
                return;
            }
        } else {
            m = (second.charAt(second.length() - 2) - '0') * 10 + second.charAt(second.length() - 1) - '0';
        }
        int[][] values = new int[][]{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                                        {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                        {2, 4, 8, 6, 2, 4, 8, 6, 2, 4, 8},
                                        {3, 9, 7, 1, 3, 9, 7, 1, 3, 9, 7},
                                        {4, 6, 4, 6, 4, 6, 4, 6, 4, 6, 4},
                                        {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
                                        {6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6},
                                        {7, 9, 3, 1, 7, 9, 3, 1, 7, 9, 3}, 
                                        {8, 4, 2, 6, 8, 4, 2, 6, 8, 4, 2},
                                        {9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9}};
        System.out.println(values[n][m % 4 + 3]);
    }
}
0