結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 566 ms
49,312 KB
testcase_01 AC 566 ms
49,096 KB
testcase_02 AC 569 ms
49,384 KB
testcase_03 AC 579 ms
49,208 KB
testcase_04 AC 570 ms
49,336 KB
testcase_05 AC 567 ms
49,380 KB
testcase_06 AC 558 ms
49,972 KB
testcase_07 AC 556 ms
49,380 KB
testcase_08 AC 561 ms
49,976 KB
testcase_09 AC 578 ms
49,224 KB
testcase_10 AC 554 ms
49,416 KB
testcase_11 AC 551 ms
49,748 KB
testcase_12 AC 557 ms
49,456 KB
testcase_13 AC 566 ms
49,260 KB
testcase_14 WA -
testcase_15 AC 562 ms
49,896 KB
testcase_16 AC 563 ms
49,404 KB
testcase_17 AC 561 ms
49,956 KB
testcase_18 AC 563 ms
49,924 KB
testcase_19 AC 556 ms
49,360 KB
testcase_20 AC 565 ms
49,844 KB
testcase_21 AC 563 ms
49,872 KB
testcase_22 AC 564 ms
49,800 KB
testcase_23 AC 564 ms
49,388 KB
testcase_24 AC 573 ms
49,340 KB
testcase_25 AC 565 ms
49,936 KB
testcase_26 WA -
testcase_27 AC 566 ms
49,496 KB
testcase_28 AC 557 ms
50,072 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
          0 -> 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