#[macro_export] macro_rules! setup { { mut $input:ident: SplitWhitespace $(,)? } => { use std::io::Read; let mut buf = String::new(); std::io::stdin().read_to_string(&mut buf).ok(); let mut $input = buf.split_whitespace(); }; } #[macro_export] macro_rules! parse_next { ($str_iter:expr) => { $str_iter.next().unwrap().parse().ok().unwrap() }; } fn main() { setup! { mut input: SplitWhitespace }; let n: usize = parse_next!(input); let m: usize = parse_next!(input); let p: f64 = parse_next!(input); let ans = (|| { let mut expv = 0.0; match (n, m) { (1, 1) => { expv += p; } (1, m) => { expv += (p * p) * (2 as f64); expv += (p * (p * p)) * ((m - 2) as f64); } (n, 1) => { expv += (p * p) * (2 as f64); expv += (p * (p * p)) * ((n - 2) as f64); } (n, m) => { let corner = 4; let edge = (n - 2) * 2 + (m - 2) * 2; let inner = (n - 2) * (m - 2); expv += (p * (p * p)) * (corner as f64); expv += (p * (p * p * p)) * (edge as f64); expv += (p * (p * p * p * p)) * (inner as f64); } } expv })(); println!("{}", ans); }