macro_rules! input { ($x:ident, $v:expr, $idx:expr) => { let $x = $v[$idx].clone(); }; ($x:ident, $v:expr, $idx:expr, $type:ty) => { let $x:$type = $v[$idx].clone().parse().unwrap(); }; ( $v:expr; $($x:ident),* ) => { let mut idx:i64 = -1; $( idx += 1; input!($x, $v, idx as usize); )* }; ( $v:expr; $($x:ident:$t:ty),* ) => { let mut idx:i64 = -1; $( idx += 1; input!($x, $v, idx as usize, $t); )* }; ( $($x:ident:$t:ty),* ) => { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let input:Vec = s.trim() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect(); let mut idx:i64 = -1; $( idx += 1; input!($x, input, idx as usize, $t); )* }; } fn main() { input!(a:f64, b:f64); const D: i64 = 10000; let dx = (b - a) / D as f64; let f = |x| { (x-a) * (x-b) * dx }; let mut result = 0.0; let mut x = a; for _i in 0..D { result += f(x).abs(); x += dx; } println!("{}", result); }