fn run() { let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); let n: usize = s.trim().parse().unwrap(); let mut dp = vec![0; n + 1]; for i in 1..=n { let mut s = i; let mut j = 1; while j * j <= i { s = std::cmp::min(s, dp[i - j * j] + j); j += 1; } dp[i] = s; } let mut a = vec![]; let mut m = n; while m > 0 { let mut find = false; let mut j = 1; while j * j <= m && !find { if dp[m - j * j] + j == dp[m] { find = true; m -= j * j; a.push(j); } j += 2; } let mut j = 2; while j * j <= m && !find { if dp[m - j * j] + j == dp[m] { find = true; m -= j * j; a.push(j); } j += 2; } } a.sort_by(|a, b| { if a % 2 == b % 2 { a.cmp(&b) } else if a % 2 == 1 { std::cmp::Ordering::Less } else { std::cmp::Ordering::Greater } }); let mut ans = String::new(); let mut prev = '0'; for mut a in a { ans.push(prev); a -= 1; while a > 1 { ans.push(if prev == '1' {'0'} else {'1'}); ans.push(prev); a -= 2; } if a > 0 { ans.push(if prev == '1' {'0'} else {'1'}); prev = if prev == '1' {'0'} else {'1'}; } } println!("{}", ans); } fn main() { run(); }