#[macro_export] macro_rules! setup { { mut $input:ident: SplitWhitespace $(,)? } => { use std::io::Read; let mut buf = String::new(); std::io::stdin().read_to_string(&mut buf).ok(); let mut $input = buf.split_whitespace(); }; } #[macro_export] macro_rules! parse_next { ($str_iter:expr) => { $str_iter.next().unwrap().parse().ok().unwrap() }; } fn main() { setup! { mut input: SplitWhitespace }; let x: u64 = parse_next!(input); // f(n) = f(n/2) + (n % 2) // f(2m) = f(m) // f(2m+1) = f(m) + 1 // 2m = m << 1 // 2m+1 = (m << 1) + 1 // m = 0: f(0) = 0, f(1) = 1 match x { x if x == 0 => { println!("{} {}", 1, 0); return; } x if x > 31 => { println!("{} {}", 0, 0); return; } _ => {} } // 2^31 - 1 = 2147483647 let ans = (|| { let count = comb(31, x); let sum = 2147483647 * comb(31 - 1, x - 1); format!("{} {}", count, sum) })(); println!("{}", ans); } fn comb(n: u64, k: u64) -> u64 { if k == 0 || k == n { return 1; } let mut ret = 1 as f64; for i in 1..=std::cmp::min(k, n - k) { ret *= ((n - i + 1) as f64) / (i as f64); } ret.trunc() as u64 }