結果

問題 No.167 N^M mod 10
ユーザー uafr_csuafr_cs
提出日時 2015-06-09 02:44:27
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 851 bytes
コンパイル時間 1,928 ms
コンパイル使用メモリ 74,688 KB
実行使用メモリ 56,684 KB
最終ジャッジ日時 2023-09-20 20:06:30
合計ジャッジ時間 6,621 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
55,748 KB
testcase_01 AC 111 ms
55,788 KB
testcase_02 AC 145 ms
56,088 KB
testcase_03 AC 151 ms
55,976 KB
testcase_04 AC 149 ms
56,312 KB
testcase_05 AC 110 ms
55,552 KB
testcase_06 AC 112 ms
55,744 KB
testcase_07 AC 107 ms
55,628 KB
testcase_08 AC 107 ms
55,696 KB
testcase_09 AC 110 ms
55,692 KB
testcase_10 AC 107 ms
55,588 KB
testcase_11 AC 106 ms
55,524 KB
testcase_12 AC 112 ms
55,672 KB
testcase_13 AC 108 ms
55,800 KB
testcase_14 WA -
testcase_15 AC 110 ms
54,176 KB
testcase_16 AC 109 ms
55,864 KB
testcase_17 AC 108 ms
55,808 KB
testcase_18 AC 111 ms
55,716 KB
testcase_19 AC 110 ms
55,808 KB
testcase_20 AC 110 ms
55,544 KB
testcase_21 AC 108 ms
55,816 KB
testcase_22 AC 153 ms
56,684 KB
testcase_23 AC 152 ms
56,512 KB
testcase_24 AC 151 ms
56,204 KB
testcase_25 AC 150 ms
56,248 KB
testcase_26 WA -
testcase_27 AC 154 ms
56,612 KB
testcase_28 AC 149 ms
56,424 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)));
		
		//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