結果

問題 No.167 N^M mod 10
ユーザー htensaihtensai
提出日時 2019-11-27 11:11:17
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 600 bytes
コンパイル時間 1,905 ms
コンパイル使用メモリ 77,588 KB
実行使用メモリ 41,588 KB
最終ジャッジ日時 2024-04-25 11:14:45
合計ジャッジ時間 7,402 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
41,028 KB
testcase_01 AC 112 ms
40,884 KB
testcase_02 AC 150 ms
41,164 KB
testcase_03 AC 137 ms
41,248 KB
testcase_04 AC 150 ms
41,296 KB
testcase_05 AC 115 ms
41,180 KB
testcase_06 AC 110 ms
41,180 KB
testcase_07 AC 95 ms
39,752 KB
testcase_08 AC 117 ms
41,212 KB
testcase_09 AC 131 ms
41,140 KB
testcase_10 AC 128 ms
41,196 KB
testcase_11 AC 132 ms
41,032 KB
testcase_12 AC 131 ms
41,392 KB
testcase_13 AC 131 ms
41,228 KB
testcase_14 WA -
testcase_15 AC 131 ms
40,968 KB
testcase_16 AC 130 ms
41,464 KB
testcase_17 AC 131 ms
41,172 KB
testcase_18 AC 132 ms
39,864 KB
testcase_19 AC 105 ms
40,144 KB
testcase_20 AC 108 ms
40,312 KB
testcase_21 AC 112 ms
39,996 KB
testcase_22 AC 145 ms
41,068 KB
testcase_23 AC 137 ms
41,432 KB
testcase_24 AC 147 ms
41,196 KB
testcase_25 AC 127 ms
41,408 KB
testcase_26 WA -
testcase_27 AC 143 ms
41,108 KB
testcase_28 AC 136 ms
40,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		char[] nArr = sc.next().toCharArray();
		int modN = nArr[nArr.length - 1] - '0';
		char[] mArr = sc.next().toCharArray();
		if (mArr.length == 0 && mArr[0] == '0') {
		    System.out.println(1);
		    return;
		}
		int modM = 0;
		for (char c : mArr) {
		    modM *= 10;
		    modM += c - '0';
		    modM %= 8;
		}
		if (modM == 0) {
		    modM = 8;
		}
		long ans = 1;
		for (int i = 1; i <= modM; i++) {
		    ans *= modN;
		}
		ans %= 10;
		System.out.println(ans);
	}
}
0