結果

問題 No.167 N^M mod 10
ユーザー spaciaspacia
提出日時 2015-12-30 00:27:49
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 629 bytes
コンパイル時間 1,943 ms
コンパイル使用メモリ 74,656 KB
実行使用メモリ 53,516 KB
最終ジャッジ日時 2023-10-19 12:30:23
合計ジャッジ時間 5,321 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 53 ms
53,504 KB
testcase_03 AC 61 ms
52,468 KB
testcase_04 WA -
testcase_05 AC 54 ms
52,380 KB
testcase_06 WA -
testcase_07 AC 51 ms
53,500 KB
testcase_08 AC 52 ms
53,516 KB
testcase_09 AC 50 ms
52,444 KB
testcase_10 AC 50 ms
53,496 KB
testcase_11 AC 52 ms
51,496 KB
testcase_12 AC 53 ms
53,504 KB
testcase_13 AC 54 ms
53,504 KB
testcase_14 AC 55 ms
53,500 KB
testcase_15 AC 57 ms
52,444 KB
testcase_16 AC 55 ms
53,500 KB
testcase_17 AC 50 ms
53,500 KB
testcase_18 AC 55 ms
53,508 KB
testcase_19 AC 50 ms
53,508 KB
testcase_20 AC 50 ms
52,480 KB
testcase_21 AC 50 ms
53,504 KB
testcase_22 AC 58 ms
53,500 KB
testcase_23 AC 55 ms
53,496 KB
testcase_24 AC 54 ms
52,452 KB
testcase_25 AC 53 ms
52,416 KB
testcase_26 AC 52 ms
53,504 KB
testcase_27 WA -
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

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 (m == 0) {
			out(1);
		} else {
			m %= 4;
			if (m == 0) m = 4;
			out((int)Math.pow(n, m) % 10);
		}
	}
}
0