結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
40,648 KB
testcase_01 WA -
testcase_02 AC 125 ms
41,348 KB
testcase_03 AC 143 ms
41,380 KB
testcase_04 WA -
testcase_05 AC 117 ms
41,212 KB
testcase_06 AC 104 ms
40,296 KB
testcase_07 AC 112 ms
41,200 KB
testcase_08 AC 104 ms
41,052 KB
testcase_09 AC 110 ms
41,276 KB
testcase_10 WA -
testcase_11 AC 100 ms
40,532 KB
testcase_12 AC 110 ms
41,296 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 111 ms
41,144 KB
testcase_18 AC 111 ms
41,576 KB
testcase_19 AC 112 ms
41,140 KB
testcase_20 AC 115 ms
41,368 KB
testcase_21 AC 113 ms
41,336 KB
testcase_22 AC 132 ms
41,380 KB
testcase_23 AC 138 ms
41,052 KB
testcase_24 AC 136 ms
41,472 KB
testcase_25 AC 142 ms
41,508 KB
testcase_26 AC 113 ms
40,160 KB
testcase_27 WA -
testcase_28 AC 134 ms
41,368 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(e == 0) ans = 1;
    if(d == 0) ans = 0;
    System.out.println(ans);
  }
}
0