結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 147 ms
41,352 KB
testcase_03 AC 144 ms
41,152 KB
testcase_04 WA -
testcase_05 AC 112 ms
41,168 KB
testcase_06 WA -
testcase_07 AC 123 ms
41,092 KB
testcase_08 AC 116 ms
41,100 KB
testcase_09 AC 117 ms
41,076 KB
testcase_10 AC 120 ms
41,068 KB
testcase_11 AC 118 ms
40,932 KB
testcase_12 AC 116 ms
40,948 KB
testcase_13 AC 107 ms
40,152 KB
testcase_14 AC 114 ms
41,012 KB
testcase_15 AC 116 ms
41,136 KB
testcase_16 AC 116 ms
41,504 KB
testcase_17 AC 116 ms
41,100 KB
testcase_18 AC 115 ms
40,984 KB
testcase_19 AC 114 ms
41,256 KB
testcase_20 AC 111 ms
41,276 KB
testcase_21 AC 105 ms
40,100 KB
testcase_22 AC 143 ms
41,228 KB
testcase_23 AC 132 ms
41,172 KB
testcase_24 AC 147 ms
41,344 KB
testcase_25 AC 141 ms
41,028 KB
testcase_26 AC 129 ms
41,196 KB
testcase_27 WA -
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

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()));
			if(m==0) System.out.println(1);
			else{
				m%=4; m+=4;
				int ans=1;
				for(int i=1;i<=m;i++) ans*=n;
				System.out.println(ans%10);
			}
		}
	}
}
0