fn read_vec() -> Vec { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() } fn main() { let abc:Vec = read_vec(); let a = abc[0]; let b = abc[1]; let c = abc[2]; let have = a + b * 100; let mut ans = None; for a_use in 0i64..=a { let a_money = a_use; for b_use in 0i64..=b { let b_money = b_use * 10; for price in 1..=have { let rest = price - a_money - b_money; if rest <= 0 { let t = rest.abs() / 10 + rest.abs() % 10; if a + b - a_use - b_use + t == c { if ans.is_none() { ans = Some(a_money+b_money+rest); } else if ans.unwrap() > a_money+b_money+rest { ans = Some(a_money+b_money+rest); } } } } } } if let Some(ans) = ans { println!("{:?}", ans); } else { println!("Impossible"); } }