結果

問題 No.167 N^M mod 10
ユーザー gemmarogemmaro
提出日時 2020-05-17 11:02:35
言語 Elixir
(1.16.2)
結果
RE  
実行時間 -
コード長 1,002 bytes
コンパイル時間 1,066 ms
コンパイル使用メモリ 55,644 KB
実行使用メモリ 51,592 KB
最終ジャッジ日時 2023-08-30 00:50:03
合計ジャッジ時間 20,058 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 572 ms
49,796 KB
testcase_01 AC 578 ms
49,056 KB
testcase_02 AC 583 ms
49,092 KB
testcase_03 AC 573 ms
49,136 KB
testcase_04 AC 561 ms
49,380 KB
testcase_05 AC 564 ms
49,932 KB
testcase_06 AC 567 ms
49,676 KB
testcase_07 AC 569 ms
49,756 KB
testcase_08 AC 561 ms
49,160 KB
testcase_09 AC 564 ms
49,232 KB
testcase_10 AC 566 ms
49,124 KB
testcase_11 AC 570 ms
49,792 KB
testcase_12 AC 560 ms
49,216 KB
testcase_13 RE -
testcase_14 WA -
testcase_15 AC 562 ms
49,568 KB
testcase_16 AC 564 ms
49,808 KB
testcase_17 AC 559 ms
50,284 KB
testcase_18 AC 556 ms
49,248 KB
testcase_19 AC 554 ms
49,848 KB
testcase_20 AC 551 ms
49,760 KB
testcase_21 AC 548 ms
49,140 KB
testcase_22 AC 555 ms
49,828 KB
testcase_23 AC 557 ms
49,352 KB
testcase_24 AC 562 ms
49,240 KB
testcase_25 AC 558 ms
49,628 KB
testcase_26 WA -
testcase_27 AC 563 ms
49,736 KB
testcase_28 AC 555 ms
49,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
  def main do
    n = IO.read(:line) |> String.trim() |> String.last() |> String.to_integer()
    m = IO.read(:line) |> String.trim() |> String.to_integer()
    solve(n, m) |> IO.puts()
  end

  def solve(n, m) do
    case n do
      0 ->
        0

      1 ->
        1

      2 ->
        case m |> rem(4) do
          1 -> 2
          2 -> 4
          3 -> 8
          4 -> 6
        end

      3 ->
        case m |> rem(4) do
          1 -> 3
          2 -> 9
          3 -> 7
          0 -> 1
        end

      4 ->
        case m |> rem(2) do
          1 -> 4
          0 -> 6
        end

      5 ->
        5

      6 ->
        6

      7 ->
        case m |> rem(4) do
          1 -> 7
          2 -> 9
          3 -> 3
          0 -> 1
        end

      8 ->
        case m |> rem(4) do
          1 -> 8
          2 -> 4
          3 -> 2
          0 -> 6
        end

      9 ->
        case m |> rem(2) do
          1 -> 9
          0 -> 1
        end
    end
  end
end
0