結果
| 問題 | No.167 N^M mod 10 |
| コンテスト | |
| ユーザー |
kenji_shioya
|
| 提出日時 | 2016-06-21 06:54:47 |
| 言語 | Java (openjdk 26.0.2.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 94 ms / 1,000 ms |
| + 693µs | |
| コード長 | 687 bytes |
| 記録 | |
| コンパイル時間 | 2,510 ms |
| コンパイル使用メモリ | 88,000 KB |
| 実行使用メモリ | 48,464 KB |
| 最終ジャッジ日時 | 2026-09-02 01:59:46 |
| 合計ジャッジ時間 | 5,886 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 27 |
ソースコード
import java.util.*;
public class Exercise104{
public static void main (String[] args){
Scanner sc = new Scanner(System.in);
String str = sc.next();
int n = Character.getNumericValue(str.charAt(str.length() - 1));
str = sc.next();
if(str.equals("0")){
System.out.println(1);
return;
}
String x = "";
if(str.length() > 1){
x += String.valueOf(str.charAt(str.length() - 2));
}
x += String.valueOf(str.charAt(str.length() - 1));
int m = Integer.parseInt(x);
int[] choises = new int[4];
for(int i = 1; i <= 4; i++){
choises[i % 4] = (int)Math.pow(n, i) % 10;
}
System.out.println(choises[m % 4]);
}
}
kenji_shioya