#[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 e = 0.0; match (n, m) { (1, 1) => { e += p; } (1, _) => { for j in 0..m { if j == 0 || j == (m - 1) { e += p * p; } else { e += p * (p * p); } } } (_, 1) => { for i in 0..n { if i == 0 || i == (n - 1) { e += p * p; } else { e += p * (p * p); } } } (_, _) => { for i in 0..n { for j in 0..m { if i == 0 || i == (n - 1) { if j == 0 || j == (m - 1) { e += p * (p * p); } else { e += p * (p * p * p); } } else { if j == 0 || j == (m - 1) { e += p * (p * p * p); } else { e += p * (p * p * p * p); } } } } } } e })(); println!("{}", ans); }