結果

問題 No.531 エヌスクミ島の平和協定
ユーザー 👑 yumechiyumechi
提出日時 2017-06-23 23:54:10
言語 Elixir
(1.16.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 353 bytes
コンパイル時間 1,352 ms
コンパイル使用メモリ 56,872 KB
最終ジャッジ日時 2023-08-29 22:42:30
合計ジャッジ時間 2,719 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
== Compilation error in file Main.exs ==
** (FunctionClauseError) no function clause matching in String.trim/1    
    
    The following arguments were given to String.trim/1:
    
        # 1
        :eof
    
    Attempted function clauses (showing 1 out of 1):
    
        def trim(+string+) when -is_binary(string)-
    
    (elixir 1.14.3) lib/string.ex:1271: String.trim/1
    Main.exs:3: Main.solve/0
    Main.exs:20: (file)

ソースコード

diff #

defmodule Main do
  def solve do
    [n, m] = IO.gets("") |> String.strip |> String.split(" ") |> Enum.map(fn(x) -> Integer.parse(x) |> elem(0) end)
    if m >= n do
      1
    else
      if rem(n, 2) == 0 do
        if m >= n/2 do
          2
        else
          -1
        end
      else
        -1
      end
    end
  end
end

IO.puts(Main.solve)
0