結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
41,140 KB
testcase_01 WA -
testcase_02 AC 144 ms
41,348 KB
testcase_03 AC 143 ms
41,204 KB
testcase_04 WA -
testcase_05 AC 115 ms
41,300 KB
testcase_06 WA -
testcase_07 AC 111 ms
40,984 KB
testcase_08 AC 118 ms
41,196 KB
testcase_09 AC 111 ms
41,160 KB
testcase_10 WA -
testcase_11 AC 105 ms
41,260 KB
testcase_12 AC 115 ms
41,012 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 101 ms
41,532 KB
testcase_16 AC 103 ms
41,748 KB
testcase_17 AC 107 ms
41,264 KB
testcase_18 AC 102 ms
41,168 KB
testcase_19 AC 114 ms
41,064 KB
testcase_20 AC 114 ms
41,272 KB
testcase_21 AC 120 ms
41,288 KB
testcase_22 AC 124 ms
41,736 KB
testcase_23 AC 147 ms
41,524 KB
testcase_24 AC 136 ms
41,456 KB
testcase_25 AC 143 ms
41,572 KB
testcase_26 AC 116 ms
41,228 KB
testcase_27 WA -
testcase_28 AC 139 ms
41,488 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);
    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