結果
| 問題 | 
                            No.959 tree and fire
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-12-22 12:59:28 | 
| 言語 | Python2  (2.7.18)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 513 bytes | 
| コンパイル時間 | 522 ms | 
| コンパイル使用メモリ | 6,944 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-14 04:31:52 | 
| 合計ジャッジ時間 | 2,581 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge6 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 47 WA * 7 | 
ソースコード
#!/usr/bin/python2
# -*- coding: utf-8 -*-
# †
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
    if res < 0:
        res = 0
    return res
N, M = map(int, raw_input().split())
p = float(raw_input())
res = f(N, M, p)
print '{:.10f}'.format(res)