fn solve(_reader: R, _writer: &mut W) { let mut _scanner = Scanner::new(_reader); #[allow(unused_macros)] macro_rules! scan { ($t:ty) => { _scanner.next::<$t>() }; ($($t:ty),+) => { ($(scan!($t)),+) }; ($t:ty; $n:expr) => {{ let mut vec = Vec::with_capacity($n); for _ in 0..$n { vec.push(scan!($t)); } vec }}; ($t_0:ty, $t_1:ty; $n:expr) => { scan!($t_0 = 0, $t_1 = 1; $n) }; ($t_0:ty, $t_1:ty, $t_2:ty; $n:expr) => { scan!($t_0 = 0, $t_1 = 1, $t_2 = 2; $n) }; ($($t:ty = $i:tt),+; $n:expr) => {{ let mut vecs = ($(Vec::<$t>::with_capacity($n)),+); for _ in 0..$n {$( vecs.$i.push(scan!($t)); )+} vecs }}; } #[allow(unused_macros)] macro_rules! println { () => { writeln!(_writer).unwrap() }; ($fmt:expr) => { writeln!(_writer, $fmt).unwrap() }; ($fmt:expr, $($arg:tt)*) => { writeln!(_writer, $fmt, $($arg)*).unwrap() }; } let k = scan!(u64); let mut cnt1 = 2; let mut comb = 1; // 2C2 while k % comb != 0 || !(k / comb).is_power_of_two() { cnt1 += 1; comb *= cnt1; comb /= cnt1 - 2; } let cnt0 = (k / comb).trailing_zeros(); let n = cnt0 as u64 + cnt1; assert_eq!(2u64.pow(cnt0) * comb, k); assert!(1 <= n && n < 30); println!("{}", n); let mut b_str = String::new(); for _ in 0..cnt0 { b_str += "0 "; } for _ in 0..cnt1 { b_str += "1 "; } println!("{}", b_str); } fn main() { let stdin = stdin(); let stdout = stdout(); #[cfg(debug_assertions)] let mut writer = stdout.lock(); #[cfg(not(debug_assertions))] let mut writer = BufWriter::new(stdout.lock()); solve(stdin.lock(), &mut writer); writer.flush().unwrap(); } use io::Scanner; use std::io::{stdin, stdout, BufRead, BufWriter, Write}; pub mod io { pub use self::scanner::*; mod scanner { use std::fmt::Debug; use std::io::BufRead; use std::str; use std::str::FromStr; pub struct Scanner { reader: R, buffer: Vec, position: usize, } impl Scanner { pub fn new(reader: R) -> Self { Scanner { reader: reader, buffer: vec![], position: 0 } } pub fn next(&mut self) -> T where T::Err: Debug, { if self.buffer.is_empty() { self.read_line(); } loop { match self.buffer.get(self.position) { Some(&b' ') => self.position += 1, Some(&b'\n') => self.read_line(), Some(_) => break, None => panic!("EOF reached"), } } let start = self.position; loop { match self.buffer.get(self.position) { Some(&b' ') | Some(&b'\n') | None => break, Some(_) => self.position += 1, } } str::from_utf8(&self.buffer[start..self.position]).unwrap().parse().unwrap() } fn read_line(&mut self) { self.position = 0; self.buffer.clear(); self.reader.read_until(b'\n', &mut self.buffer).unwrap(); } } } }