結果

問題 No.167 N^M mod 10
ユーザー mits58mits58
提出日時 2016-07-09 17:23:24
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 453 bytes
コンパイル時間 1,944 ms
コンパイル使用メモリ 74,312 KB
実行使用メモリ 41,616 KB
最終ジャッジ日時 2024-04-21 10:46:16
合計ジャッジ時間 6,470 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
41,028 KB
testcase_01 AC 114 ms
41,136 KB
testcase_02 AC 140 ms
41,416 KB
testcase_03 AC 150 ms
41,404 KB
testcase_04 AC 148 ms
41,212 KB
testcase_05 AC 116 ms
41,452 KB
testcase_06 AC 121 ms
40,816 KB
testcase_07 AC 113 ms
41,036 KB
testcase_08 AC 112 ms
40,976 KB
testcase_09 AC 106 ms
39,936 KB
testcase_10 AC 117 ms
41,388 KB
testcase_11 AC 120 ms
41,420 KB
testcase_12 AC 116 ms
41,276 KB
testcase_13 AC 108 ms
40,112 KB
testcase_14 WA -
testcase_15 AC 114 ms
41,176 KB
testcase_16 AC 113 ms
40,908 KB
testcase_17 AC 112 ms
40,672 KB
testcase_18 AC 104 ms
39,876 KB
testcase_19 AC 112 ms
40,968 KB
testcase_20 AC 114 ms
41,244 KB
testcase_21 AC 100 ms
40,100 KB
testcase_22 AC 144 ms
41,496 KB
testcase_23 AC 145 ms
41,120 KB
testcase_24 AC 146 ms
41,616 KB
testcase_25 AC 146 ms
41,428 KB
testcase_26 WA -
testcase_27 AC 144 ms
41,064 KB
testcase_28 AC 141 ms
41,052 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; m+=4;
			int ans=1;
			for(int i=1;i<=m;i++) ans*=n;
			System.out.println(ans%10);
		}
	}
}
0