結果

問題 No.167 N^M mod 10
ユーザー kou6839kou6839
提出日時 2015-03-20 00:16:40
言語 Java19
(openjdk 21)
結果
AC  
実行時間 147 ms / 1,000 ms
コード長 488 bytes
コンパイル時間 2,626 ms
コンパイル使用メモリ 77,344 KB
実行使用メモリ 57,620 KB
最終ジャッジ日時 2023-10-21 23:41:19
合計ジャッジ時間 6,551 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
56,900 KB
testcase_01 AC 111 ms
57,384 KB
testcase_02 AC 147 ms
57,592 KB
testcase_03 AC 144 ms
57,596 KB
testcase_04 AC 146 ms
57,596 KB
testcase_05 AC 112 ms
57,388 KB
testcase_06 AC 99 ms
56,284 KB
testcase_07 AC 111 ms
57,372 KB
testcase_08 AC 112 ms
57,524 KB
testcase_09 AC 110 ms
57,516 KB
testcase_10 AC 120 ms
57,400 KB
testcase_11 AC 110 ms
57,408 KB
testcase_12 AC 103 ms
56,344 KB
testcase_13 AC 108 ms
57,596 KB
testcase_14 AC 115 ms
57,392 KB
testcase_15 AC 109 ms
57,620 KB
testcase_16 AC 101 ms
56,220 KB
testcase_17 AC 100 ms
56,308 KB
testcase_18 AC 111 ms
57,336 KB
testcase_19 AC 112 ms
57,392 KB
testcase_20 AC 110 ms
57,400 KB
testcase_21 AC 111 ms
57,416 KB
testcase_22 AC 146 ms
57,416 KB
testcase_23 AC 131 ms
57,368 KB
testcase_24 AC 131 ms
57,292 KB
testcase_25 AC 132 ms
57,532 KB
testcase_26 AC 126 ms
57,260 KB
testcase_27 AC 143 ms
57,552 KB
testcase_28 AC 126 ms
57,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;


public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String a=sc.next();
		String b = sc.next();
		long c = Long.parseLong(a.charAt(a.length()-1)+"");
		long aa = 0;
		if(b.length()>1){
			aa = Long.parseLong(b.substring(b.length()-2, b.length()));
			if(aa==0)aa=100;
		}else {
			aa=Long.parseLong(b.charAt(b.length()-1)+"");
			
		}
		
		aa-=1;
		aa%=4;
		aa++;
		System.out.println((int)(Math.pow(c, aa)%10));
	}
}
0