結果

問題 No.167 N^M mod 10
ユーザー kenkooookenkoooo
提出日時 2015-03-19 23:47:45
言語 Java19
(openjdk 21)
結果
AC  
実行時間 167 ms / 1,000 ms
コード長 566 bytes
コンパイル時間 2,177 ms
コンパイル使用メモリ 74,468 KB
実行使用メモリ 57,624 KB
最終ジャッジ日時 2023-10-21 23:39:55
合計ジャッジ時間 7,408 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
57,360 KB
testcase_01 AC 130 ms
57,416 KB
testcase_02 AC 161 ms
57,376 KB
testcase_03 AC 162 ms
57,572 KB
testcase_04 AC 165 ms
57,572 KB
testcase_05 AC 132 ms
57,424 KB
testcase_06 AC 127 ms
57,172 KB
testcase_07 AC 125 ms
57,372 KB
testcase_08 AC 120 ms
57,056 KB
testcase_09 AC 121 ms
57,404 KB
testcase_10 AC 115 ms
56,128 KB
testcase_11 AC 126 ms
57,184 KB
testcase_12 AC 130 ms
57,444 KB
testcase_13 AC 127 ms
57,376 KB
testcase_14 AC 126 ms
57,272 KB
testcase_15 AC 127 ms
57,356 KB
testcase_16 AC 127 ms
55,392 KB
testcase_17 AC 126 ms
55,648 KB
testcase_18 AC 126 ms
57,376 KB
testcase_19 AC 128 ms
55,204 KB
testcase_20 AC 129 ms
57,216 KB
testcase_21 AC 127 ms
57,308 KB
testcase_22 AC 163 ms
57,372 KB
testcase_23 AC 158 ms
57,404 KB
testcase_24 AC 163 ms
57,560 KB
testcase_25 AC 160 ms
57,396 KB
testcase_26 AC 142 ms
57,444 KB
testcase_27 AC 167 ms
57,596 KB
testcase_28 AC 167 ms
57,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] N = sc.next().toCharArray();
		String mString = sc.next();
		sc.close();
		int a = Character.getNumericValue(N[N.length - 1]);
		int b = 0;
		if (mString.length() > 2) {
			b = Integer.parseInt(mString.substring(mString.length() - 2, mString.length()));
			b %= 4;
			b += 4;
		} else {
			b = Integer.parseInt(mString);
			if (b != 0) {
				b %= 4;
				b += 4;
			}
		}

		System.out.println((int) (Math.pow(a, b) % 10));

	}
}
0