結果

問題 No.959 tree and fire
ユーザー gemmarogemmaro
提出日時 2020-04-25 13:34:53
言語 Elixir
(1.16.2)
結果
WA  
実行時間 -
コード長 787 bytes
コンパイル時間 1,583 ms
コンパイル使用メモリ 54,164 KB
実行使用メモリ 50,736 KB
最終ジャッジ日時 2023-08-30 00:41:21
合計ジャッジ時間 39,949 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 616 ms
49,620 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 628 ms
49,676 KB
testcase_04 AC 629 ms
50,356 KB
testcase_05 AC 628 ms
49,660 KB
testcase_06 AC 628 ms
49,680 KB
testcase_07 AC 630 ms
49,592 KB
testcase_08 AC 630 ms
49,740 KB
testcase_09 AC 621 ms
49,760 KB
testcase_10 AC 630 ms
50,416 KB
testcase_11 AC 620 ms
50,368 KB
testcase_12 WA -
testcase_13 AC 632 ms
49,684 KB
testcase_14 AC 617 ms
49,836 KB
testcase_15 WA -
testcase_16 AC 627 ms
50,216 KB
testcase_17 AC 617 ms
49,552 KB
testcase_18 AC 626 ms
49,804 KB
testcase_19 AC 621 ms
50,540 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 621 ms
49,516 KB
testcase_23 AC 625 ms
49,792 KB
testcase_24 AC 630 ms
50,472 KB
testcase_25 AC 626 ms
49,704 KB
testcase_26 AC 630 ms
50,540 KB
testcase_27 AC 627 ms
50,324 KB
testcase_28 AC 628 ms
49,564 KB
testcase_29 AC 628 ms
49,568 KB
testcase_30 AC 640 ms
50,320 KB
testcase_31 AC 630 ms
50,736 KB
testcase_32 AC 630 ms
49,536 KB
testcase_33 AC 629 ms
49,504 KB
testcase_34 AC 633 ms
49,748 KB
testcase_35 AC 632 ms
49,724 KB
testcase_36 AC 628 ms
49,884 KB
testcase_37 AC 619 ms
50,732 KB
testcase_38 AC 632 ms
49,580 KB
testcase_39 AC 636 ms
50,212 KB
testcase_40 AC 629 ms
49,680 KB
testcase_41 AC 641 ms
49,852 KB
testcase_42 AC 626 ms
49,596 KB
testcase_43 AC 632 ms
50,308 KB
testcase_44 AC 634 ms
49,524 KB
testcase_45 AC 644 ms
49,440 KB
testcase_46 AC 634 ms
49,640 KB
testcase_47 AC 631 ms
49,540 KB
testcase_48 AC 641 ms
50,584 KB
testcase_49 AC 644 ms
49,568 KB
testcase_50 AC 639 ms
50,148 KB
testcase_51 AC 634 ms
49,536 KB
testcase_52 AC 630 ms
50,432 KB
testcase_53 AC 632 ms
49,576 KB
testcase_54 AC 632 ms
50,200 KB
testcase_55 AC 615 ms
50,184 KB
testcase_56 AC 631 ms
49,624 KB
権限があれば一括ダウンロードができます

ソースコード

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()
      |> (fn s ->
            case s do
              "0" -> 0
              "1" -> 1
              _ -> s |> String.to_float()
            end
          end).()

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

  def solve({n, m}, p) do
    case {n, m} do
      {1, 1} -> p
      {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