fn main() { let mut k = String::new(); std::io::stdin().read_line(&mut k).ok(); let k: usize = k.trim().parse().unwrap(); if k == 0 { println!("1"); println!("1"); return; } let calc = |c: usize, r: usize| (c+1-r..=c).fold(1usize, |x, y| x * y) / (1..1+r).fold(1usize, |x, y| x * y); for c in 2..=250 { for r in 2..=c { let combval = calc(r, 2); if combval == k { println!("{}", c); println!("{}", (0..c).map(|i| if i < r { "1" } else { "3" }).collect::>().join(" ")); return; } else if combval > k { break; } } } for c in 4..=250 { for r1 in 2..=c { let comb1 = calc(r1, 2); if comb1 > k { break; } for r2 in 1..=c-r1 { let comb2 = r2 * (c-r1-r2); if comb1 + comb2 > k { break; } if comb1 + comb2 == k { println!("{}", c); println!("{}", (0..c).map(|i| if i < r1 { "1" } else if i < r1+r2 { "3" } else { "8" }).collect::>().join(" ")); return; } } } } }