結果

問題 No.167 N^M mod 10
ユーザー takeya_okinotakeya_okino
提出日時 2019-08-22 19:38:35
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 625 bytes
コンパイル時間 2,379 ms
コンパイル使用メモリ 77,096 KB
実行使用メモリ 54,800 KB
最終ジャッジ日時 2024-04-20 21:45:33
合計ジャッジ時間 7,404 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
54,208 KB
testcase_01 WA -
testcase_02 AC 133 ms
53,948 KB
testcase_03 AC 131 ms
54,008 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 RE -
testcase_07 AC 114 ms
53,916 KB
testcase_08 AC 117 ms
53,936 KB
testcase_09 AC 103 ms
52,744 KB
testcase_10 WA -
testcase_11 RE -
testcase_12 AC 113 ms
53,968 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 105 ms
52,832 KB
testcase_18 AC 104 ms
52,876 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 149 ms
53,720 KB
testcase_23 AC 136 ms
53,836 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 119 ms
53,036 KB
testcase_27 WA -
testcase_28 AC 149 ms
53,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String n = sc.next();
    String m = sc.next();
    int d = Integer.parseInt(String.valueOf(n.charAt(n.length() - 1)));
    int e = 0;
    if(m.length() > 1) {
      e = Integer.parseInt(String.valueOf(m.charAt(n.length() - 2)) + String.valueOf(m.charAt(n.length() - 1)));
    } else {
      e = Integer.parseInt(String.valueOf(m.charAt(0)));
    }
    e = (e % 4);
    int ans = 1;
    for(int i = 0; i < e; i++) {
      ans *= d;
    }
    if(d == 0) ans = 0;
    System.out.println(ans);
  }
}
0