use std::io::*; fn check(a: f64, b: f64, y: f64, z: f64, w: f64) -> bool { if (y * y + a * a + w * w - 2. * w * (y * y + a * a).sqrt() - z * z - b * b).abs() < 1e-6 { return true; } false } fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let x: usize = itr.next().unwrap().parse().unwrap(); let y: f64 = itr.next().unwrap().parse().unwrap(); let z: f64 = itr.next().unwrap().parse().unwrap(); let w: f64 = itr.next().unwrap().parse().unwrap(); for i in 1..x + 1 { if i * i > x { break; } if x % i == 0 { let a = i as f64; let b = (x / i) as f64; if check(a, b, y, z, w) { let ans = x as f64 - y * a / 2. - z * b / 2. - (b - y) * (a - z) / 2.; println!("{:.10}", ans); return; } if check(b, a, y, z, w) { let ans = x as f64 - y * b / 2. - z * a / 2. - (a - y) * (b - z) / 2.; println!("{:.10}", ans); return; } } } }