結果

問題 No.167 N^M mod 10
ユーザー gemmarogemmaro
提出日時 2020-05-17 11:00:07
言語 Elixir
(1.16.2)
結果
RE  
実行時間 -
コード長 1,026 bytes
コンパイル時間 908 ms
コンパイル使用メモリ 63,256 KB
実行使用メモリ 55,356 KB
最終ジャッジ日時 2024-06-10 00:02:26
合計ジャッジ時間 18,130 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 544 ms
54,020 KB
testcase_01 AC 538 ms
53,872 KB
testcase_02 AC 593 ms
55,100 KB
testcase_03 AC 584 ms
54,524 KB
testcase_04 AC 574 ms
54,620 KB
testcase_05 AC 546 ms
54,540 KB
testcase_06 AC 531 ms
53,812 KB
testcase_07 AC 533 ms
54,008 KB
testcase_08 AC 524 ms
53,700 KB
testcase_09 AC 534 ms
54,064 KB
testcase_10 AC 534 ms
53,820 KB
testcase_11 AC 536 ms
54,008 KB
testcase_12 AC 531 ms
53,696 KB
testcase_13 RE -
testcase_14 WA -
testcase_15 AC 534 ms
54,272 KB
testcase_16 AC 545 ms
54,416 KB
testcase_17 AC 535 ms
54,088 KB
testcase_18 AC 553 ms
54,160 KB
testcase_19 AC 523 ms
54,000 KB
testcase_20 AC 536 ms
54,192 KB
testcase_21 AC 519 ms
53,808 KB
testcase_22 AC 580 ms
55,300 KB
testcase_23 AC 580 ms
54,988 KB
testcase_24 AC 565 ms
54,704 KB
testcase_25 AC 575 ms
54,888 KB
testcase_26 WA -
testcase_27 AC 564 ms
54,956 KB
testcase_28 AC 562 ms
54,588 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