結果

問題 No.959 tree and fire
ユーザー TANIGUCHI Kousuke
提出日時 2020-01-07 18:46:27
言語 Ruby
(3.4.1)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 250 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,672 KB
最終ジャッジ日時 2024-11-23 01:04:11
合計ジャッジ時間 7,366 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 54
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N,M = gets.split.map(&:to_i).sort
P = gets.to_f

def ans
  if N > 1 && M > 1
    4 * P ** 3 + ((M - 2) * 2 + (N - 2) * 2) * P ** 4 + (M - 2) * (N - 2) * P ** 5
  elsif M > 1
    2 * P ** 2 + (M - 2) * P ** 3
  else
    P
  end
end

puts '%0.7f' % ans
0