fn combinations(n: usize, r: usize) -> Vec> { let mut result: Vec> = vec![vec![]]; if n == 0 || r == 0 { return result; } for j in 0..n { let limit = result.len(); for i in 0..limit { if result[i].len() < r && n - j >= r - result[i].len() { let mut selected = result[i].clone(); selected.push(j); result.push(selected); } } } result.iter().filter(|&val| val.len() == r).map(|i| i.clone()).collect() } //TODO fn main() { let mut x = String::new(); std::io::stdin().read_line(&mut x).ok(); let x: usize = x.trim().parse().unwrap(); if x > 31 { println!("0 0"); return; } let ranks: Vec = (0..31).map(|i| 2usize.pow(i as u32)).collect(); let combs = combinations(31, x); let count = combs.len(); let result: usize = combs.iter() .map(|vals| vals.iter().map(|&i| ranks[i]).sum::()) .sum(); println!("{} {}", count, result); }