結果

問題 No.167 N^M mod 10
ユーザー takeya_okinotakeya_okino
提出日時 2019-08-22 19:57:55
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 667 bytes
コンパイル時間 2,014 ms
コンパイル使用メモリ 76,796 KB
実行使用メモリ 41,548 KB
最終ジャッジ日時 2024-04-20 22:09:46
合計ジャッジ時間 6,429 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
40,768 KB
testcase_01 WA -
testcase_02 AC 148 ms
41,548 KB
testcase_03 AC 146 ms
41,332 KB
testcase_04 WA -
testcase_05 AC 117 ms
41,364 KB
testcase_06 AC 111 ms
41,084 KB
testcase_07 AC 111 ms
41,500 KB
testcase_08 AC 111 ms
41,160 KB
testcase_09 AC 119 ms
41,036 KB
testcase_10 WA -
testcase_11 AC 101 ms
40,048 KB
testcase_12 AC 99 ms
40,348 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 114 ms
41,468 KB
testcase_18 AC 104 ms
40,120 KB
testcase_19 AC 111 ms
41,196 KB
testcase_20 AC 107 ms
40,268 KB
testcase_21 AC 118 ms
41,536 KB
testcase_22 AC 146 ms
40,972 KB
testcase_23 AC 153 ms
41,188 KB
testcase_24 AC 143 ms
41,096 KB
testcase_25 AC 136 ms
41,200 KB
testcase_26 AC 110 ms
40,480 KB
testcase_27 WA -
testcase_28 AC 133 ms
41,116 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)));
    }
    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