use std::collections::HashMap; fn calc(val: usize) -> usize { let mut ret = 0usize; for i in 1..=(val as f64).sqrt() as usize { if val % i == 0 { ret += i; if i != val / i { ret += val / i; } } } ret } fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: usize = n.trim().parse().unwrap(); if n == 0 { println!("-1"); return; } let nstr = format!("{:b}", n).chars().collect::>(); let mut length = nstr.len(); let mut result = vec![]; let mut base = 1usize << (length-1); let mut current = 0usize; loop { while format!("{:b}", calc(base)).len() != length { base += 1; } current ^= calc(base); result.push(base); if current == n { break; } let current_str = format!("{:b}", current).chars().collect::>(); length = nstr.len() - (0..nstr.len()).filter(|&i| nstr[i] != current_str[i]).nth(0).unwrap(); base = 1usize << (length - 1); } println!("{}", result.len()); println!("{}", result.iter().map(|v| v.to_string()).collect::>().join(" ")); }