from decimal import Decimal, getcontext getcontext().prec = 30 # Set sufficient precision for calculations n, m = map(int, input().split()) p_str = input().strip() p = Decimal(p_str) # Calculate the number of rows for each possible a (adjacent up/down count) def calculate_rows(n): cnt = [0] * 3 if n == 1: cnt[0] = 1 else: cnt[0] = 0 if n >= 2: cnt[1] = 2 else: cnt[1] = 0 cnt[2] = max(n - 2, 0) if n >= 3 else 0 return cnt # Calculate the number of columns for each possible b (adjacent left/right count) def calculate_cols(m): cnt = [0] * 3 if m == 1: cnt[0] = 1 else: cnt[0] = 0 if m >= 2: cnt[1] = 2 else: cnt[1] = 0 cnt[2] = max(m - 2, 0) if m >= 3 else 0 return cnt cnt_rows = calculate_rows(n) cnt_cols = calculate_cols(m) result = Decimal(0) for a in range(3): for b in range(3): current_count = cnt_rows[a] * cnt_cols[b] if current_count == 0: continue exponent = a + b + 1 term = (current_count) * (p ** exponent) result += term # Ensure output has exactly 10 decimal places formatted_result = format(result, '.10f') print(formatted_result)