use fio::*; const N: usize = 14; fn main() { let a = read::(); let [p0, p1, p2] = read_tuple::(); let (p0, p1, p2) = (p0 as f64 / 100.0, p1 as f64 / 100.0, p2 as f64 / 100.0); let mut dp = vec![0.0; 1 << N]; dp[(1 << N) - 1] = 1.0; for _ in 0..80 - a { let mut ndp = vec![0.0; 1 << N]; for i in 0..1 << N { let mut pp = vec![0f64; N]; for k in 0..N { let val = ((i << 1) >> k) & 5; pp[k] = match val { 0 => p0, 1 | 4 => p1, 5 => p2, _ => unreachable!(), } } let mut j = i; loop { let mut prob = 1.0; for k in 0..N { if i & (1 << k) == 0 { continue; } prob *= if j & (1 << k) == 0 { pp[k] } else { 1.0 - pp[k] } } ndp[j] += prob * dp[i]; if j == 0 { break; } else { j = (j - 1) & i; } } } dp = ndp; } eprintln!("{:?}", &dp); let ans = 2.0 * dp.into_iter() .enumerate() .map(|(i, x)| i.count_ones() as f64 * x) .sum::(); println!("{ans:.9}"); } mod fio { use std::{ cell::RefCell, convert::TryInto, fmt::Debug, io::{BufRead, BufWriter, StdinLock, StdoutLock, stdin, stdout}, str::FromStr, }; thread_local! { pub static STDIN: RefCell> = RefCell::new(stdin().lock()); pub static STDOUT: RefCell>> = RefCell::new(BufWriter::new(stdout().lock())); } #[allow(dead_code)] pub fn read() -> T where ::Err: Debug, { read_line().parse().unwrap() } #[allow(dead_code)] pub fn read_vec() -> Vec where ::Err: Debug, { read_line() .split_whitespace() .map(|x| x.parse().unwrap()) .collect() } #[allow(dead_code)] pub fn read_tuple() -> [T; N] where T: FromStr + Debug, ::Err: Debug, { read_vec::().try_into().unwrap() } /// whitespace at the end of the line is ignored pub fn read_line() -> String { let mut s = String::new(); STDIN.with(|cell| { cell.borrow_mut().read_line(&mut s).unwrap(); }); String::from_str(s.trim_end()).unwrap() } } #[macro_export] macro_rules! print { ($($t:tt)*) => { fio::STDOUT.with(|cell|{ use std::io::Write; write!(cell.borrow_mut(), $($t)*).unwrap() })}; } #[macro_export] macro_rules! println { ($($t:tt)*) => { fio::STDOUT.with(|cell| { use std::io::Write; writeln!(cell.borrow_mut(), $($t)*).unwrap() }) }; } #[macro_export] macro_rules! flush { () => { fio::STDOUT.with(|cell| { use std::io::Write; cell.borrow_mut().flush().unwrap() }); }; }