結果
| 問題 |
No.959 tree and fire
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-12-22 13:17:17 |
| 言語 | Python2 (2.7.18) |
| 結果 |
AC
|
| 実行時間 | 24 ms / 2,000 ms |
| コード長 | 506 bytes |
| コンパイル時間 | 422 ms |
| コンパイル使用メモリ | 7,200 KB |
| 実行使用メモリ | 8,320 KB |
| 最終ジャッジ日時 | 2024-09-14 04:50:28 |
| 合計ジャッジ時間 | 3,790 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 54 |
ソースコード
#!/usr/bin/python2
# -*- coding: utf-8 -*-
# †
from decimal import *
def f(N, M, p):
if N > M:
N, M = M, N
s = [0] * 5
if N == 1:
if M > 1:
s[1] = 2
s[2] = M-2
else:
s[2] = 4
s[3] = 2 * (N-2 + M-2)
s[4] = (N-2) * (M-2)
res = N*M * p
for i in [1, 2, 3, 4]:
res -= s[i] * (1-p**i) * p
return res
N, M = map(int, raw_input().split())
p = Decimal(raw_input())
res = f(N, M, p)
print '{:.10f}'.format(res)