結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
49,500 KB
testcase_01 AC 45 ms
49,448 KB
testcase_02 AC 100 ms
52,684 KB
testcase_03 AC 100 ms
52,084 KB
testcase_04 AC 97 ms
51,708 KB
testcase_05 AC 45 ms
49,600 KB
testcase_06 AC 44 ms
49,476 KB
testcase_07 AC 46 ms
49,524 KB
testcase_08 AC 45 ms
49,404 KB
testcase_09 AC 44 ms
49,380 KB
testcase_10 AC 45 ms
47,356 KB
testcase_11 AC 45 ms
49,440 KB
testcase_12 AC 45 ms
49,524 KB
testcase_13 AC 45 ms
49,440 KB
testcase_14 AC 46 ms
49,172 KB
testcase_15 AC 47 ms
49,440 KB
testcase_16 AC 45 ms
49,496 KB
testcase_17 AC 45 ms
49,448 KB
testcase_18 AC 45 ms
49,180 KB
testcase_19 AC 45 ms
49,544 KB
testcase_20 AC 47 ms
49,208 KB
testcase_21 AC 46 ms
49,508 KB
testcase_22 AC 88 ms
52,388 KB
testcase_23 AC 90 ms
53,088 KB
testcase_24 AC 100 ms
52,624 KB
testcase_25 AC 100 ms
51,844 KB
testcase_26 AC 83 ms
51,916 KB
testcase_27 WA -
testcase_28 AC 99 ms
52,348 KB
権限があれば一括ダウンロードができます

ソースコード

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&&M.length==1)
			System.out.println("1");
		else {
			int ans = n;
			for (int i = 1; i < m; i++)
				ans = (ans * n) % 10;
			System.out.println(ans);
		}
	}
}
0