結果

問題 No.167 N^M mod 10
ユーザー Vir_MeL0Vir_MeL0
提出日時 2017-03-22 23:44:26
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 731 bytes
コンパイル時間 2,191 ms
コンパイル使用メモリ 72,324 KB
実行使用メモリ 53,352 KB
最終ジャッジ日時 2023-09-19 05:30:19
合計ジャッジ時間 5,339 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 90 ms
51,276 KB
testcase_03 AC 100 ms
51,728 KB
testcase_04 WA -
testcase_05 AC 46 ms
49,752 KB
testcase_06 WA -
testcase_07 AC 45 ms
49,208 KB
testcase_08 AC 46 ms
49,400 KB
testcase_09 AC 45 ms
49,544 KB
testcase_10 AC 45 ms
49,216 KB
testcase_11 AC 46 ms
49,488 KB
testcase_12 AC 45 ms
49,464 KB
testcase_13 AC 47 ms
49,396 KB
testcase_14 AC 46 ms
49,500 KB
testcase_15 AC 46 ms
49,692 KB
testcase_16 AC 45 ms
49,368 KB
testcase_17 AC 47 ms
49,716 KB
testcase_18 AC 46 ms
49,524 KB
testcase_19 AC 45 ms
49,352 KB
testcase_20 AC 45 ms
49,364 KB
testcase_21 AC 45 ms
49,692 KB
testcase_22 AC 103 ms
52,004 KB
testcase_23 AC 102 ms
52,268 KB
testcase_24 AC 102 ms
51,568 KB
testcase_25 AC 99 ms
52,496 KB
testcase_26 AC 89 ms
51,716 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)
			System.out.println("1");
		else {
			int ans = n;
			for (int i = 1; i < m; i++)
				ans = (ans * n) % 10;
			System.out.println(ans);
		}
	}
}
0