結果

問題 No.167 N^M mod 10
ユーザー YamaKasa
提出日時 2018-07-25 21:38:07
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 482 bytes
コンパイル時間 2,020 ms
コンパイル使用メモリ 75,788 KB
実行使用メモリ 54,664 KB
最終ジャッジ日時 2024-06-27 03:35:25
合計ジャッジ時間 7,001 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String N = scan.next();
		String M = scan.next();
		scan.close();
		int n = Integer.parseInt(N.substring(N.length() - 1, N.length()));
		int m = 0;
		if(M.length() < 2) {
			m = Integer.parseInt(M);
		}else {
			m = Integer.parseInt(M.substring(M.length() - 2, M.length()));
		}

		m = m % 4;
		System.out.println((int)Math.pow(n, m + 4) % 10);

	}
}
0