fn calc(t: usize) -> usize { let mut s = 0usize; let op = format!("{:b}", t).chars().map(|c| c as usize - '0' as usize).collect::>(); let mut t = 0usize; for &v in op.iter() { t *= 2; t += v; s += t; } s } fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: usize = n.trim().parse().unwrap(); let mut lower = 0usize; let mut upper = 1usize << 30; while upper > lower { let middle = (upper + lower) / 2; let val = calc(middle); if n == val { println!("YES"); return; } if n < val { upper = middle; } else { lower = middle + 1; } } if calc(upper) == n { println!("YES"); } else { println!("NO"); } }