結果

問題 No.167 N^M mod 10
ユーザー takeya_okinotakeya_okino
提出日時 2019-08-22 19:52:11
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 637 bytes
コンパイル時間 2,040 ms
コンパイル使用メモリ 86,468 KB
実行使用メモリ 41,868 KB
最終ジャッジ日時 2024-04-20 22:05:16
合計ジャッジ時間 6,483 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
40,728 KB
testcase_01 WA -
testcase_02 AC 144 ms
41,336 KB
testcase_03 AC 136 ms
41,468 KB
testcase_04 WA -
testcase_05 AC 102 ms
40,876 KB
testcase_06 AC 114 ms
41,048 KB
testcase_07 AC 101 ms
41,008 KB
testcase_08 AC 103 ms
40,080 KB
testcase_09 AC 112 ms
40,896 KB
testcase_10 WA -
testcase_11 AC 97 ms
40,872 KB
testcase_12 AC 100 ms
40,980 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 109 ms
41,108 KB
testcase_18 AC 103 ms
41,568 KB
testcase_19 AC 108 ms
40,772 KB
testcase_20 AC 116 ms
40,680 KB
testcase_21 AC 103 ms
40,568 KB
testcase_22 AC 142 ms
41,408 KB
testcase_23 AC 143 ms
41,348 KB
testcase_24 AC 136 ms
41,448 KB
testcase_25 AC 143 ms
41,488 KB
testcase_26 AC 130 ms
41,260 KB
testcase_27 WA -
testcase_28 AC 141 ms
41,524 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(m.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 = (ans * d) % 10;
    }
    if(d == 0) ans = 0;
    System.out.println(ans);
  }
}
0