use std::collections::VecDeque; const INF: usize = 1usize << 60; fn get_priority(length: usize) -> usize { if length % 2 == 1 { length } else { INF - length } } 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.. { let val = j * j; if val > i { break; } dp[i] = dp[i].min(dp[i-val]+j); } } let mut use_lengths = vec![]; let mut target = n; while target > 0 { for i in 1.. { let val = i*i; if val > target { break; } if dp[target-val]+i == dp[target] { use_lengths.push(i); target -= val; break; } } } use_lengths.sort_by_key(|&v| get_priority(v)); let odds = use_lengths.iter().filter(|&&v| v % 2 == 1).copied().collect::>(); let mut evens = use_lengths.iter().filter(|&&v| v % 2 == 0).copied().collect::>(); let mut result = String::new(); for &v in odds.iter() { result.push_str(format!("0{}", "10".repeat(v/2)).as_str()); } let limit = evens.len(); for i in 0..limit { if i % 2 == 0 { result.push_str(format!("{}", "01".repeat(evens.pop_front().unwrap()/2)).as_str()); } else { result.push_str(format!("{}", "10".repeat(evens.pop_back().unwrap()/2)).as_str()); } } println!("{}", result); }