結果

問題 No.167 N^M mod 10
ユーザー htensaihtensai
提出日時 2019-11-27 11:24:03
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 678 bytes
コンパイル時間 2,307 ms
コンパイル使用メモリ 73,884 KB
実行使用メモリ 41,596 KB
最終ジャッジ日時 2024-04-25 11:29:04
合計ジャッジ時間 7,259 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
40,276 KB
testcase_01 AC 99 ms
39,572 KB
testcase_02 AC 144 ms
41,508 KB
testcase_03 AC 138 ms
41,116 KB
testcase_04 AC 153 ms
41,556 KB
testcase_05 AC 110 ms
40,832 KB
testcase_06 AC 120 ms
40,944 KB
testcase_07 AC 121 ms
40,992 KB
testcase_08 AC 125 ms
40,972 KB
testcase_09 AC 113 ms
41,596 KB
testcase_10 AC 107 ms
40,152 KB
testcase_11 AC 116 ms
41,256 KB
testcase_12 AC 128 ms
41,216 KB
testcase_13 AC 114 ms
39,948 KB
testcase_14 WA -
testcase_15 AC 126 ms
41,044 KB
testcase_16 AC 126 ms
41,064 KB
testcase_17 AC 129 ms
41,148 KB
testcase_18 AC 127 ms
41,416 KB
testcase_19 AC 131 ms
41,088 KB
testcase_20 AC 127 ms
41,144 KB
testcase_21 AC 128 ms
41,160 KB
testcase_22 AC 163 ms
41,416 KB
testcase_23 AC 163 ms
41,560 KB
testcase_24 AC 153 ms
40,996 KB
testcase_25 AC 142 ms
41,396 KB
testcase_26 WA -
testcase_27 AC 140 ms
41,268 KB
testcase_28 AC 140 ms
41,232 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;
		}
		if (nArr.length == 0 && nArr[0] == '0') {
		    System.out.println(0);
		    return;
		}
		int modM = 0;
		for (char c : mArr) {
		    modM *= 10;
		    modM += c - '0';
		    modM %= 8;
		}
		modM %= 4;
		modM += 4;
		long ans = 1;
		for (int i = 1; i <= modM; i++) {
		    ans *= modN;
		}
		ans %= 10;
		System.out.println(ans);
	}
}
0