結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 618 ms
49,860 KB
testcase_01 AC 623 ms
49,160 KB
testcase_02 AC 622 ms
50,000 KB
testcase_03 AC 617 ms
50,152 KB
testcase_04 AC 617 ms
50,624 KB
testcase_05 AC 617 ms
49,916 KB
testcase_06 AC 610 ms
49,948 KB
testcase_07 AC 619 ms
49,280 KB
testcase_08 AC 616 ms
49,220 KB
testcase_09 AC 614 ms
49,344 KB
testcase_10 AC 613 ms
49,256 KB
testcase_11 AC 613 ms
49,336 KB
testcase_12 AC 617 ms
49,708 KB
testcase_13 RE -
testcase_14 WA -
testcase_15 AC 620 ms
49,460 KB
testcase_16 AC 619 ms
49,768 KB
testcase_17 AC 619 ms
49,220 KB
testcase_18 AC 622 ms
49,252 KB
testcase_19 AC 621 ms
49,224 KB
testcase_20 AC 619 ms
50,120 KB
testcase_21 AC 620 ms
49,888 KB
testcase_22 AC 624 ms
49,880 KB
testcase_23 AC 620 ms
49,452 KB
testcase_24 AC 624 ms
49,384 KB
testcase_25 AC 631 ms
49,424 KB
testcase_26 WA -
testcase_27 AC 622 ms
50,016 KB
testcase_28 AC 620 ms
49,952 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.slice(-2..-1) |> 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