結果

問題 No.167 N^M mod 10
ユーザー uafr_csuafr_cs
提出日時 2015-06-09 02:45:47
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 855 bytes
コンパイル時間 2,126 ms
コンパイル使用メモリ 75,024 KB
実行使用メモリ 58,244 KB
最終ジャッジ日時 2023-09-20 20:06:40
合計ジャッジ時間 7,171 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
55,532 KB
testcase_01 AC 116 ms
56,048 KB
testcase_02 AC 146 ms
56,044 KB
testcase_03 AC 159 ms
56,876 KB
testcase_04 AC 152 ms
56,120 KB
testcase_05 AC 117 ms
55,540 KB
testcase_06 AC 115 ms
55,452 KB
testcase_07 AC 117 ms
55,680 KB
testcase_08 AC 116 ms
55,388 KB
testcase_09 AC 116 ms
55,996 KB
testcase_10 AC 117 ms
55,416 KB
testcase_11 AC 117 ms
55,308 KB
testcase_12 AC 116 ms
55,748 KB
testcase_13 AC 116 ms
55,812 KB
testcase_14 WA -
testcase_15 AC 116 ms
55,488 KB
testcase_16 AC 115 ms
55,304 KB
testcase_17 AC 115 ms
55,572 KB
testcase_18 AC 116 ms
56,476 KB
testcase_19 AC 115 ms
55,764 KB
testcase_20 AC 115 ms
55,604 KB
testcase_21 AC 116 ms
55,576 KB
testcase_22 AC 149 ms
53,884 KB
testcase_23 AC 154 ms
56,568 KB
testcase_24 AC 149 ms
56,092 KB
testcase_25 AC 148 ms
56,232 KB
testcase_26 WA -
testcase_27 AC 159 ms
56,040 KB
testcase_28 AC 147 ms
58,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String N = sc.next();
		String M = sc.next();
		
		int[][] answers = {
				{0},
				{1},
				{2, 4, 8, 6},
				{3, 9, 7, 1},
				{4, 6},
				{5},
				{6},
				{7, 9, 3, 1},
				{8, 4, 2, 6},
				{9, 1},
		};
		
		final int N_mod_10 = Integer.parseInt(N.substring(N.length() - 1));
		final int M_mod_100 = Integer.parseInt(M.substring(Math.max(0, M.length() - 2))) % 4;
		
		//System.out.println(N_mod_10 + ":" + M_mod_100);
		System.out.println(answers[N_mod_10]["0".equals(M) ? 0 : (answers[N_mod_10].length + M_mod_100 - 1) % answers[N_mod_10].length]);
		
	}
	
}
0