結果

問題 No.167 N^M mod 10
ユーザー kenkooookenkoooo
提出日時 2015-03-19 23:44:57
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 520 bytes
コンパイル時間 2,185 ms
コンパイル使用メモリ 72,352 KB
実行使用メモリ 56,692 KB
最終ジャッジ日時 2023-09-11 08:44:07
合計ジャッジ時間 7,201 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,780 KB
testcase_01 AC 120 ms
55,600 KB
testcase_02 AC 153 ms
56,388 KB
testcase_03 AC 154 ms
56,176 KB
testcase_04 AC 153 ms
56,348 KB
testcase_05 AC 120 ms
55,428 KB
testcase_06 AC 120 ms
55,588 KB
testcase_07 AC 121 ms
55,884 KB
testcase_08 AC 119 ms
55,856 KB
testcase_09 WA -
testcase_10 AC 120 ms
55,592 KB
testcase_11 AC 120 ms
55,908 KB
testcase_12 AC 120 ms
55,880 KB
testcase_13 AC 120 ms
56,168 KB
testcase_14 AC 119 ms
55,320 KB
testcase_15 AC 119 ms
55,908 KB
testcase_16 AC 120 ms
56,140 KB
testcase_17 AC 119 ms
55,612 KB
testcase_18 AC 119 ms
56,124 KB
testcase_19 AC 120 ms
56,088 KB
testcase_20 AC 122 ms
55,512 KB
testcase_21 AC 119 ms
55,608 KB
testcase_22 AC 151 ms
56,128 KB
testcase_23 AC 154 ms
56,560 KB
testcase_24 AC 152 ms
56,692 KB
testcase_25 AC 152 ms
56,180 KB
testcase_26 AC 136 ms
55,864 KB
testcase_27 AC 151 ms
56,180 KB
testcase_28 AC 155 ms
56,432 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);
		}

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

	}
}
0