結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,516 KB
testcase_01 AC 121 ms
55,732 KB
testcase_02 AC 152 ms
56,600 KB
testcase_03 AC 153 ms
56,612 KB
testcase_04 AC 155 ms
56,420 KB
testcase_05 AC 119 ms
55,716 KB
testcase_06 AC 118 ms
56,004 KB
testcase_07 AC 119 ms
56,020 KB
testcase_08 AC 119 ms
55,532 KB
testcase_09 AC 120 ms
56,060 KB
testcase_10 AC 119 ms
55,700 KB
testcase_11 AC 118 ms
55,700 KB
testcase_12 AC 118 ms
55,640 KB
testcase_13 AC 119 ms
55,756 KB
testcase_14 WA -
testcase_15 AC 122 ms
56,024 KB
testcase_16 AC 122 ms
55,520 KB
testcase_17 AC 119 ms
55,740 KB
testcase_18 AC 121 ms
55,556 KB
testcase_19 AC 120 ms
55,732 KB
testcase_20 AC 124 ms
55,756 KB
testcase_21 AC 118 ms
55,568 KB
testcase_22 AC 159 ms
56,736 KB
testcase_23 AC 151 ms
56,052 KB
testcase_24 AC 152 ms
56,360 KB
testcase_25 AC 152 ms
56,352 KB
testcase_26 WA -
testcase_27 AC 160 ms
56,036 KB
testcase_28 AC 153 ms
56,696 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()));
		} else {
			b = Integer.parseInt(mString);
		}
		b %= 4;
		b += 4;

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

	}
}
0