結果

問題 No.167 N^M mod 10
ユーザー takeya_okinotakeya_okino
提出日時 2019-08-22 20:13:56
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 691 bytes
コンパイル時間 2,880 ms
コンパイル使用メモリ 76,816 KB
実行使用メモリ 41,608 KB
最終ジャッジ日時 2024-04-20 22:29:29
合計ジャッジ時間 8,027 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
41,464 KB
testcase_01 WA -
testcase_02 AC 164 ms
41,500 KB
testcase_03 AC 169 ms
41,224 KB
testcase_04 WA -
testcase_05 AC 128 ms
41,144 KB
testcase_06 WA -
testcase_07 AC 128 ms
41,452 KB
testcase_08 AC 137 ms
41,264 KB
testcase_09 AC 131 ms
41,384 KB
testcase_10 AC 126 ms
41,284 KB
testcase_11 AC 127 ms
41,316 KB
testcase_12 AC 127 ms
41,208 KB
testcase_13 AC 117 ms
40,148 KB
testcase_14 WA -
testcase_15 AC 130 ms
41,380 KB
testcase_16 AC 135 ms
41,392 KB
testcase_17 AC 134 ms
41,140 KB
testcase_18 AC 134 ms
41,252 KB
testcase_19 AC 132 ms
41,272 KB
testcase_20 AC 129 ms
41,088 KB
testcase_21 AC 138 ms
41,260 KB
testcase_22 AC 147 ms
41,212 KB
testcase_23 AC 161 ms
41,416 KB
testcase_24 AC 162 ms
41,156 KB
testcase_25 AC 163 ms
41,276 KB
testcase_26 AC 152 ms
41,300 KB
testcase_27 WA -
testcase_28 AC 163 ms
41,420 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(m.length() - 1)));
    } else {
      e = Integer.parseInt(String.valueOf(m.charAt(0)));
    }
    int e1 = (e % 4);
    if(e1 == 0) e1 = 4;
    int ans = 1;
    for(int i = 0; i < e1; i++) {
      ans = (ans * d) % 10;
    }
    if(e == 0) ans = 1;
    if(d == 0) ans = 0;
    System.out.println(ans);
  }
}
0