use std::{collections::BinaryHeap, cmp::Reverse}; const INF: usize = 1usize << 60; fn priority(val: usize, flg: bool) -> usize { if val % 2 == 1 { val } else if !flg { INF - val } else { INF + val } } fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: usize = n.trim().parse().unwrap(); let mut dp = vec![INF; n+1]; dp[0] = 0; for i in 1..=n { for j in 1..=i { let val = j * j; if val > i { break; } dp[i] = dp[i].min(dp[i-val] + j); } } let mut result = String::new(); let mut target = n; while target > 0 { let mut pque = BinaryHeap::new(); let flg = if result.is_empty() || result.ends_with('0') { false } else { true }; for i in 1..=target { let val = i * i; if val > target { break; } if dp[target-val] + i == dp[target] { pque.push((Reverse(priority(i, flg)), i)); } } let (_, i) = pque.pop().unwrap(); let val = if i % 2 == 1 { format!("0{}", "10".repeat(i/2)) } else if flg { "10".repeat(i/2).to_string() } else { "01".repeat(i/2).to_string() }; result.push_str(&val); target -= i * i; } println!("{}", result); }