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