結果

問題 No.959 tree and fire
ユーザー gemmaro
提出日時 2020-04-25 13:28:17
言語 Elixir
(1.18.1)
結果
WA  
実行時間 -
コード長 634 bytes
コンパイル時間 1,003 ms
コンパイル使用メモリ 63,480 KB
実行使用メモリ 57,084 KB
最終ジャッジ日時 2024-12-31 04:40:29
合計ジャッジ時間 34,506 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37 WA * 7 RE * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
    warning: missing parentheses on expression following operator "+", you must add parentheses to avoid ambiguities
    │
 25 │         (if(n <= 2, do: 0, else: (n - 2) * 2) + if(m <= 2, do: 0, else: (m - 2) * 2)) +
    │         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    │
    └─ Main.exs:25

ソースコード

diff #

defmodule Main do
  def main do
    [n, m] =
      IO.read(:line)
      |> String.trim()
      |> String.split()
      |> Enum.map(&String.to_integer/1)

    p =
      IO.read(:line)
      |> String.trim()
      |> String.to_float()

    solve({n, m}, p)
    |> IO.puts()
  end

  def solve({n, m}, p) do
    case {n, m} do
      {1, _} -> m * :math.pow(p, 2)
      {_, 1} -> n * :math.pow(p, 2)
      _ -> 4 * :math.pow(p, 3)
    end +
      :math.pow(p, 4) *
        (if(n <= 2, do: 0, else: (n - 2) * 2) + if(m <= 2, do: 0, else: (m - 2) * 2)) +
      :math.pow(p, 5) * if n <= 2 || m <= 2, do: 0, else: (n - 2) * (m - 2)
  end
end
0