結果

問題 No.167 N^M mod 10
ユーザー crazybbb3crazybbb3
提出日時 2017-01-29 01:07:55
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 2,258 bytes
コンパイル時間 4,436 ms
コンパイル使用メモリ 75,540 KB
実行使用メモリ 50,348 KB
最終ジャッジ日時 2023-09-08 13:41:36
合計ジャッジ時間 5,582 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
49,852 KB
testcase_01 AC 52 ms
49,852 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 59 ms
50,296 KB
testcase_05 AC 51 ms
50,056 KB
testcase_06 AC 51 ms
49,900 KB
testcase_07 AC 51 ms
50,348 KB
testcase_08 AC 52 ms
50,028 KB
testcase_09 AC 53 ms
49,824 KB
testcase_10 AC 52 ms
50,108 KB
testcase_11 AC 52 ms
49,904 KB
testcase_12 AC 51 ms
49,800 KB
testcase_13 AC 50 ms
50,008 KB
testcase_14 AC 50 ms
49,912 KB
testcase_15 AC 50 ms
49,868 KB
testcase_16 AC 51 ms
49,756 KB
testcase_17 AC 52 ms
49,960 KB
testcase_18 AC 51 ms
49,996 KB
testcase_19 AC 51 ms
49,812 KB
testcase_20 AC 50 ms
49,932 KB
testcase_21 AC 50 ms
49,888 KB
testcase_22 AC 59 ms
49,852 KB
testcase_23 AC 58 ms
50,012 KB
testcase_24 AC 59 ms
49,856 KB
testcase_25 AC 57 ms
49,836 KB
testcase_26 AC 54 ms
47,724 KB
testcase_27 AC 57 ms
47,868 KB
testcase_28 AC 58 ms
50,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {

    void solve() throws IOException {
        int[][] t = {
                {0, 0, 0, 0},
                {1, 1, 1, 1},
                {6, 2, 4, 7},
                {1, 3, 9, 7},
                {6, 4, 6, 4},
                {5, 5, 5, 5},
                {6, 6, 6, 6},
                {1, 7, 9, 3},
                {6, 8, 4, 2},
                {1, 9, 1, 9}
        };

        String n = ns(), m = "0" + ns();
        if (m.equals("00")) {
            out.println(1);
            return;
        }
        int nn = Integer.valueOf(n.substring(n.length() - 1));
        int mm = Integer.valueOf(m.substring(m.length() - 2)) % 4;
        out.println(t[nn][mm]);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}
0