結果

問題 No.167 N^M mod 10
ユーザー YamaKasaYamaKasa
提出日時 2018-07-25 21:38:07
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 482 bytes
コンパイル時間 2,032 ms
コンパイル使用メモリ 71,708 KB
実行使用メモリ 56,940 KB
最終ジャッジ日時 2023-09-09 10:26:48
合計ジャッジ時間 7,326 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
56,304 KB
testcase_01 AC 109 ms
56,048 KB
testcase_02 AC 150 ms
56,940 KB
testcase_03 AC 148 ms
56,032 KB
testcase_04 AC 148 ms
56,372 KB
testcase_05 AC 115 ms
55,796 KB
testcase_06 AC 114 ms
56,076 KB
testcase_07 AC 114 ms
56,032 KB
testcase_08 AC 114 ms
56,124 KB
testcase_09 AC 115 ms
56,104 KB
testcase_10 AC 117 ms
55,976 KB
testcase_11 AC 116 ms
55,832 KB
testcase_12 AC 115 ms
55,764 KB
testcase_13 AC 110 ms
56,008 KB
testcase_14 WA -
testcase_15 AC 111 ms
56,168 KB
testcase_16 AC 115 ms
55,572 KB
testcase_17 AC 117 ms
56,192 KB
testcase_18 AC 114 ms
55,336 KB
testcase_19 AC 114 ms
55,504 KB
testcase_20 AC 114 ms
55,600 KB
testcase_21 AC 115 ms
55,960 KB
testcase_22 AC 149 ms
56,152 KB
testcase_23 AC 157 ms
56,136 KB
testcase_24 AC 147 ms
56,596 KB
testcase_25 AC 142 ms
54,996 KB
testcase_26 WA -
testcase_27 AC 143 ms
55,936 KB
testcase_28 AC 147 ms
56,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String N = scan.next();
		String M = scan.next();
		scan.close();
		int n = Integer.parseInt(N.substring(N.length() - 1, N.length()));
		int m = 0;
		if(M.length() < 2) {
			m = Integer.parseInt(M);
		}else {
			m = Integer.parseInt(M.substring(M.length() - 2, M.length()));
		}

		m = m % 4;
		System.out.println((int)Math.pow(n, m + 4) % 10);

	}
}
0