https://atcoder.jp/contests/math-and-algorithm/tasks/math_and_algorithm_ax
届くかと偶奇の判定だけですね。
// Move on Squares 1 #![allow(non_snake_case)] //////////////////// library //////////////////// fn read<T: std::str::FromStr>() -> T { let mut line = String::new(); std::io::stdin().read_line(&mut line).ok(); line.trim().parse().ok().unwrap() } fn read_vec<T: std::str::FromStr>() -> Vec<T> { read::<String>().split_whitespace() .map(|e| e.parse().ok().unwrap()).collect() } fn YesNo(b: bool) -> String { return if b { "Yes".to_string() } else { "No".to_string() } } //////////////////// process //////////////////// fn read_input() -> (i64, i64, i64) { let v = read_vec(); (v[0], v[1], v[2]) } fn f(N: i64, X: i64, Y: i64) -> bool { N >= X.abs() + Y.abs() && (X + Y - N) % 2 == 0 } fn main() { let (N, X, Y) = read_input(); println!("{}", YesNo(f(N, X, Y))) }