結果

問題 No.167 N^M mod 10
ユーザー takeya_okinotakeya_okino
提出日時 2019-08-22 19:50:36
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 629 bytes
コンパイル時間 1,980 ms
コンパイル使用メモリ 76,768 KB
実行使用メモリ 54,524 KB
最終ジャッジ日時 2024-04-20 22:02:11
合計ジャッジ時間 6,460 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
41,332 KB
testcase_01 AC 99 ms
41,272 KB
testcase_02 AC 125 ms
41,120 KB
testcase_03 AC 136 ms
41,552 KB
testcase_04 AC 134 ms
41,252 KB
testcase_05 WA -
testcase_06 AC 110 ms
40,780 KB
testcase_07 AC 108 ms
40,888 KB
testcase_08 AC 111 ms
40,864 KB
testcase_09 AC 112 ms
41,268 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 98 ms
40,112 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 100 ms
40,300 KB
testcase_18 AC 106 ms
41,504 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 134 ms
41,544 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 133 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(n.length() - 1)));
    } else {
      e = Integer.parseInt(String.valueOf(m.charAt(0)));
    }
    e = (e % 4);
    int ans = d;
    for(int i = 0; i < e - 1; i++) {
      ans *= d;
    }
    if(d == 0) ans = 0;
    System.out.println(ans);
  }
}
0