use std::io; use std::io::BufRead; use std::io::Lines; use std::io::StdinLock; #[derive(Debug)] struct Input { yuki_hotel_fee: u32, other_hotel_fee: u32, count: u32, reservations: Vec } fn read_next(iter: &mut Lines) -> Option { match iter.next() { Some(res) => Some(res.unwrap().parse().unwrap()), None => None } } fn create_input() -> Input { let mut reservations = Vec::new(); let stdin = io::stdin(); let mut lines = stdin.lock().lines(); let yuki_fee = read_next(&mut lines).unwrap(); let other_fee = read_next(&mut lines).unwrap(); let count = read_next(&mut lines).unwrap(); while let Some(data) = read_next(&mut lines) { reservations.push(data); } Input {yuki_hotel_fee: yuki_fee, other_hotel_fee: other_fee, count: count, reservations: reservations} } fn calcurate(input: &Input) -> u32 { let target_count: u32 = input.reservations.as_slice().into_iter().sum(); (input.yuki_hotel_fee + input.other_hotel_fee) * target_count } fn main() { let input = create_input(); let result = calcurate(&input); println!("{}", result); }