結果

問題 No.167 N^M mod 10
ユーザー Vir_MeL0Vir_MeL0
提出日時 2017-03-22 23:48:35
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 782 bytes
コンパイル時間 2,028 ms
コンパイル使用メモリ 71,300 KB
実行使用メモリ 54,432 KB
最終ジャッジ日時 2023-09-19 05:30:35
合計ジャッジ時間 5,238 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 99 ms
52,372 KB
testcase_03 AC 99 ms
51,752 KB
testcase_04 WA -
testcase_05 AC 46 ms
49,176 KB
testcase_06 WA -
testcase_07 AC 45 ms
49,180 KB
testcase_08 AC 45 ms
49,220 KB
testcase_09 AC 45 ms
49,456 KB
testcase_10 AC 46 ms
49,516 KB
testcase_11 AC 45 ms
49,476 KB
testcase_12 AC 46 ms
49,480 KB
testcase_13 AC 46 ms
49,464 KB
testcase_14 AC 46 ms
49,508 KB
testcase_15 AC 45 ms
49,396 KB
testcase_16 AC 46 ms
49,416 KB
testcase_17 AC 45 ms
49,364 KB
testcase_18 AC 46 ms
49,408 KB
testcase_19 AC 45 ms
49,472 KB
testcase_20 AC 46 ms
49,360 KB
testcase_21 AC 45 ms
49,448 KB
testcase_22 AC 99 ms
51,708 KB
testcase_23 AC 103 ms
52,676 KB
testcase_24 AC 99 ms
51,748 KB
testcase_25 AC 103 ms
51,296 KB
testcase_26 AC 85 ms
51,236 KB
testcase_27 WA -
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] N = str.split("");
		int n = Integer.parseInt(N[N.length - 1]);
		str = br.readLine();
		String[] M = str.split("");
		int m = 0;
		if (M.length == 1)
			m = Integer.parseInt(M[0]);
		else {
			m = Integer.parseInt(M[M.length - 2]) * 10
					+ Integer.parseInt(M[M.length - 1]);
		}
		if (m == 0) {
			if (M.length == 1)
				System.out.println("1");
			else
				m = 4;
		} else {
			int ans = n;
			for (int i = 1; i < m; i++)
				ans = (ans * n) % 10;
			System.out.println(ans);
		}
	}
}
0