結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 45 ms
49,460 KB
testcase_06 WA -
testcase_07 AC 45 ms
49,364 KB
testcase_08 AC 45 ms
49,396 KB
testcase_09 AC 44 ms
49,212 KB
testcase_10 AC 45 ms
49,408 KB
testcase_11 AC 45 ms
49,184 KB
testcase_12 AC 44 ms
49,644 KB
testcase_13 AC 45 ms
49,484 KB
testcase_14 AC 44 ms
47,872 KB
testcase_15 AC 45 ms
49,288 KB
testcase_16 AC 45 ms
49,440 KB
testcase_17 AC 46 ms
49,212 KB
testcase_18 AC 45 ms
49,448 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
権限があれば一括ダウンロードができます

ソースコード

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();
		int n = Integer.parseInt(str) % 10;
		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