solutions: 466A
This commit is contained in:
parent
76be42d4a0
commit
781a18e0fa
1 changed files with 30 additions and 0 deletions
30
solutions/rust/src/bin/466A.rs
Normal file
30
solutions/rust/src/bin/466A.rs
Normal file
|
@ -0,0 +1,30 @@
|
|||
use std::io;
|
||||
|
||||
fn main() {
|
||||
let mut s = String::new();
|
||||
io::stdin().read_line(&mut s).unwrap();
|
||||
|
||||
let inp = s.trim().split_whitespace().map(|i| i.parse::<f64>().unwrap()).collect::<Vec<f64>>();
|
||||
|
||||
let n = inp[0];
|
||||
let m = inp[1];
|
||||
let a = inp[2];
|
||||
let b = inp[3];
|
||||
|
||||
let mut price: f64;
|
||||
|
||||
if b > a {
|
||||
price = b * (n/m).floor() + a * (n%m);
|
||||
if m > n && n*a > b {
|
||||
price = b;
|
||||
} else if n*a < b && n*a < price {
|
||||
price = a;
|
||||
} else if n*a < price {
|
||||
price = n*a;
|
||||
}
|
||||
} else {
|
||||
price = b * (n/m).ceil();
|
||||
}
|
||||
|
||||
println!("{}", price);
|
||||
}
|
Loading…
Reference in a new issue