結果

問題 No.167 N^M mod 10
ユーザー spaciaspacia
提出日時 2015-12-30 00:32:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 58 ms / 1,000 ms
コード長 637 bytes
コンパイル時間 2,910 ms
コンパイル使用メモリ 74,484 KB
実行使用メモリ 53,436 KB
最終ジャッジ日時 2023-10-21 23:58:03
合計ジャッジ時間 4,636 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
51,384 KB
testcase_01 AC 54 ms
53,432 KB
testcase_02 AC 56 ms
53,424 KB
testcase_03 AC 57 ms
53,428 KB
testcase_04 AC 55 ms
53,436 KB
testcase_05 AC 54 ms
53,428 KB
testcase_06 AC 54 ms
53,432 KB
testcase_07 AC 54 ms
53,420 KB
testcase_08 AC 54 ms
52,348 KB
testcase_09 AC 54 ms
53,420 KB
testcase_10 AC 54 ms
53,420 KB
testcase_11 AC 54 ms
52,332 KB
testcase_12 AC 55 ms
53,432 KB
testcase_13 AC 54 ms
53,428 KB
testcase_14 AC 54 ms
53,424 KB
testcase_15 AC 53 ms
53,424 KB
testcase_16 AC 53 ms
52,328 KB
testcase_17 AC 55 ms
53,428 KB
testcase_18 AC 55 ms
53,424 KB
testcase_19 AC 54 ms
52,332 KB
testcase_20 AC 54 ms
53,424 KB
testcase_21 AC 54 ms
53,424 KB
testcase_22 AC 56 ms
53,428 KB
testcase_23 AC 58 ms
53,428 KB
testcase_24 AC 56 ms
53,428 KB
testcase_25 AC 57 ms
52,312 KB
testcase_26 AC 55 ms
53,424 KB
testcase_27 AC 55 ms
53,424 KB
testcase_28 AC 55 ms
53,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.math.*;

class Main167 {
	
	public static void out (Object out) {
		System.out.println(out);
	}
	
	public static void main (String[] args) throws IOException {
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		String s1 = br.readLine();
		String s2 = br.readLine();
		
		int n = s1.charAt(s1.length() - 1) - '0';
		int m = s2.length() >= 2 ? Integer.parseInt(s2.substring(s2.length() - 2 , s2.length())) : Integer.parseInt(s2);
		
		if (s2.equals("0")) {
			out(1);
		} else {
			m %= 4;
			if (m == 0) m = 4;
			out((int)Math.pow(n, m) % 10);
		}
	}
}
0