23 lines
700 B
Rust
Executable File
23 lines
700 B
Rust
Executable File
use math;
|
|
|
|
fn quadratic_formula(a: i32, b: i32, c: i32) -> (f64, f64)
|
|
{
|
|
let square = b*b-4*a*c;
|
|
let temp = (square as f64).sqrt();
|
|
return (math::round::ceil(((-b as f64+temp)/((2*a) as f64)) +0.00001, 0), math::round::ceil(((-b as f64 -temp)/((2*a) as f64)) - 0.00001, 0));
|
|
}
|
|
|
|
fn main() {
|
|
let mut answer = 1.0;
|
|
// let times = [7,15,30];
|
|
// let distances = [9,40,200];
|
|
let times = [63,78,94,68];
|
|
let distances = [411,1274,2047,1035];
|
|
for index in 0..times.len() {
|
|
let (a, b) = quadratic_formula(-1, times[index], -distances[index]);
|
|
println!("{} {}", a, b);
|
|
answer = answer * (b-a);
|
|
}
|
|
println!("{}", answer);
|
|
}
|