結果

問題 No.167 N^M mod 10
ユーザー kou6839
提出日時 2015-03-20 00:04:24
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 466 bytes
コンパイル時間 2,394 ms
コンパイル使用メモリ 77,856 KB
実行使用メモリ 54,460 KB
最終ジャッジ日時 2024-06-28 23:29:58
合計ジャッジ時間 7,441 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21 WA * 6
権限があれば一括ダウンロードができます

ソースコード

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 = Integer.parseInt(a.charAt(a.length()-1)+"");
		long aa = 0;
		if(b.length()>1){
			aa = Integer.parseInt(b.substring(b.length()-2, b.length()));
		}else{
			aa=Integer.parseInt(b.charAt(b.length()-1)+"");
		}
		aa-=1;
		aa%=4;
		aa++;
		System.out.println((int)(Math.pow(c, aa)%10));
	}
}
0