結果

問題 No.46 はじめのn歩
コンテスト
ユーザー midolin limegreen
提出日時 2019-01-02 22:38:12
言語 Elixir
(1.20.4)
コンパイル:
elixirc _filename_
実行:
elixir -e Main.main
結果
AC  
実行時間 302 ms / 5,000 ms
+ 610µs
コード長 394 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 515 ms
コンパイル使用メモリ 78,512 KB
実行使用メモリ 67,104 KB
最終ジャッジ日時 2026-10-09 19:42:27
合計ジャッジ時間 4,859 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
    warning: this clause cannot match because a previous clause at line 8 always matches
    │
  9 │         _ -> 0
    │           ~
    │
    └─ Main.exs:9:11

    warning: the following clause cannot match because the previous clauses already matched all possible values:

        _ ->

    it attempts to match on the result of:

        {div(Enum.at(x, 1), Enum.at(x, 0)), rem(Enum.at(x, 1), Enum.at(x, 0))}

    which has the already matched type:

        dynamic({integer(), integer()})

    type warning found at:
    │
  9 │         _ -> 0
    │           ~
    │
    └─ Main.exs:9:11: Main.main/0

ソースコード

diff #
raw source code

defmodule Main do
  def main do
      x = IO.gets("") |> String.trim
                      |> String.split(" ", trim: true)
                      |> Enum.map(&String.to_integer/1)
      case {div(x |> Enum.at(1), x |> Enum.at(0)), rem(x |> Enum.at(1), x |> Enum.at(0))} do
        {n, 0} -> n
        {n, _} -> n + 1
        _ -> 0
      end |> Integer.to_string
          |> IO.puts
  end
end
0