結果

問題 No.167 N^M mod 10
ユーザー mits58mits58
提出日時 2016-07-09 17:22:11
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 446 bytes
コンパイル時間 2,593 ms
コンパイル使用メモリ 75,208 KB
実行使用メモリ 54,740 KB
最終ジャッジ日時 2024-04-21 10:46:03
合計ジャッジ時間 7,773 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
41,164 KB
testcase_01 AC 122 ms
41,140 KB
testcase_02 AC 159 ms
41,484 KB
testcase_03 AC 142 ms
41,356 KB
testcase_04 AC 157 ms
41,284 KB
testcase_05 AC 111 ms
40,176 KB
testcase_06 AC 126 ms
41,364 KB
testcase_07 AC 122 ms
41,140 KB
testcase_08 AC 124 ms
41,444 KB
testcase_09 AC 122 ms
41,436 KB
testcase_10 WA -
testcase_11 AC 124 ms
41,396 KB
testcase_12 AC 112 ms
40,116 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 125 ms
40,876 KB
testcase_16 AC 125 ms
41,072 KB
testcase_17 AC 122 ms
41,548 KB
testcase_18 AC 111 ms
40,032 KB
testcase_19 AC 110 ms
39,888 KB
testcase_20 AC 123 ms
41,128 KB
testcase_21 AC 125 ms
41,060 KB
testcase_22 WA -
testcase_23 AC 157 ms
41,248 KB
testcase_24 AC 141 ms
41,388 KB
testcase_25 AC 160 ms
41,264 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 162 ms
41,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			String s1=sc.next();
			String s2=sc.next();
			int n=s1.charAt(s1.length()-1)-'0';
			int m=0;
			if(s2.length()<3) m=Integer.valueOf(s2);
			else m=Integer.valueOf(s2.substring(s2.length()-2,s2.length()));
			m%=4;
			int ans=n;
			for(int i=1;i<m;i++) ans*=n;
			System.out.println(ans%10);
		}
	}
}
0