結果

問題 No.959 tree and fire
ユーザー gemmarogemmaro
提出日時 2020-04-25 13:44:03
言語 Elixir
(1.16.2)
結果
WA  
実行時間 -
コード長 866 bytes
コンパイル時間 1,067 ms
コンパイル使用メモリ 56,324 KB
実行使用メモリ 50,720 KB
最終ジャッジ日時 2023-08-30 00:42:09
合計ジャッジ時間 40,133 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 632 ms
50,080 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 617 ms
49,744 KB
testcase_04 AC 646 ms
49,452 KB
testcase_05 AC 622 ms
50,548 KB
testcase_06 AC 624 ms
49,496 KB
testcase_07 AC 628 ms
50,212 KB
testcase_08 AC 619 ms
49,648 KB
testcase_09 AC 638 ms
49,448 KB
testcase_10 AC 631 ms
49,736 KB
testcase_11 AC 634 ms
50,288 KB
testcase_12 WA -
testcase_13 AC 628 ms
50,296 KB
testcase_14 AC 631 ms
50,444 KB
testcase_15 WA -
testcase_16 AC 618 ms
49,592 KB
testcase_17 AC 635 ms
49,716 KB
testcase_18 AC 636 ms
50,168 KB
testcase_19 AC 620 ms
50,244 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 615 ms
49,652 KB
testcase_23 AC 621 ms
50,252 KB
testcase_24 AC 626 ms
49,700 KB
testcase_25 AC 627 ms
49,648 KB
testcase_26 AC 631 ms
50,720 KB
testcase_27 AC 635 ms
49,864 KB
testcase_28 AC 627 ms
49,772 KB
testcase_29 AC 619 ms
49,736 KB
testcase_30 AC 629 ms
49,728 KB
testcase_31 AC 628 ms
49,720 KB
testcase_32 AC 633 ms
50,108 KB
testcase_33 AC 627 ms
49,808 KB
testcase_34 AC 617 ms
50,212 KB
testcase_35 AC 613 ms
49,820 KB
testcase_36 AC 617 ms
49,444 KB
testcase_37 AC 614 ms
49,804 KB
testcase_38 AC 619 ms
49,536 KB
testcase_39 AC 619 ms
50,216 KB
testcase_40 AC 635 ms
50,236 KB
testcase_41 AC 625 ms
49,792 KB
testcase_42 AC 622 ms
49,732 KB
testcase_43 AC 622 ms
49,696 KB
testcase_44 AC 625 ms
49,440 KB
testcase_45 AC 624 ms
49,448 KB
testcase_46 AC 626 ms
49,444 KB
testcase_47 AC 622 ms
49,716 KB
testcase_48 AC 622 ms
49,544 KB
testcase_49 AC 620 ms
50,260 KB
testcase_50 AC 618 ms
49,528 KB
testcase_51 AC 614 ms
50,016 KB
testcase_52 AC 628 ms
49,588 KB
testcase_53 AC 618 ms
50,176 KB
testcase_54 AC 624 ms
49,536 KB
testcase_55 AC 624 ms
50,324 KB
testcase_56 AC 623 ms
49,604 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, 2} ->
        2 * :math.pow(p, 2)

      {1, _} ->
        m * :math.pow(p, 2) + :math.pow(p, 3) * (m - 2)

      {2, 1} ->
        2 * :math.pow(p, 2)

      {_, 1} ->
        n * :math.pow(p, 2) + :math.pow(p, 3) * (n - 2)

      _ ->
        4 * :math.pow(p, 3) + :math.pow(p, 4) * (2 * n + 2 * m - 8) +
          :math.pow(p, 5) * (n - 2) * (m - 2)
    end
  end
end
0