結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
41,404 KB
testcase_01 AC 94 ms
39,812 KB
testcase_02 AC 122 ms
41,420 KB
testcase_03 AC 122 ms
41,280 KB
testcase_04 AC 128 ms
41,136 KB
testcase_05 AC 97 ms
40,248 KB
testcase_06 AC 106 ms
41,204 KB
testcase_07 AC 106 ms
41,224 KB
testcase_08 AC 110 ms
40,936 KB
testcase_09 AC 96 ms
40,120 KB
testcase_10 AC 111 ms
40,976 KB
testcase_11 AC 105 ms
41,092 KB
testcase_12 AC 95 ms
39,900 KB
testcase_13 AC 106 ms
40,820 KB
testcase_14 WA -
testcase_15 AC 105 ms
40,308 KB
testcase_16 AC 114 ms
41,120 KB
testcase_17 AC 104 ms
41,144 KB
testcase_18 AC 104 ms
40,940 KB
testcase_19 AC 98 ms
39,872 KB
testcase_20 AC 100 ms
40,280 KB
testcase_21 AC 96 ms
40,276 KB
testcase_22 AC 135 ms
41,144 KB
testcase_23 AC 138 ms
41,300 KB
testcase_24 AC 142 ms
41,216 KB
testcase_25 AC 134 ms
41,044 KB
testcase_26 WA -
testcase_27 AC 125 ms
41,296 KB
testcase_28 AC 140 ms
41,276 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(0);
		}
		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