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, 0); n + 1]; for i in 1..=n { let mut s = dp[i - 1]; s.0 += 1; s.1 += 1; let mut j = 2; while j * j <= i { let v = dp[i - j * j]; if s.0 > v.0 + j { s = v; s.0 += j; } else if s.0 == v.0 + j && s.1 < v.1 { s = v; s.0 += j; } j += 1; } dp[i] = s; } let mut a = vec![]; let mut m = n; while m > 0 { if dp[m].1 > 0 { a.push(1); m -= 1; continue; } let mut find = false; let mut j = 3; while j * j <= m && !find{ if dp[m - j * j].0 + j == dp[m].0 { find = true; m -= j * j; a.push(j); } j += 2; } let mut j = 2; while j * j <= m && !find { if dp[m - j * j].0 + j == dp[m].0 { find = true; m -= j * j; a.push(j); } j += 2; } } a.sort_by(|a, b| { if a % 2 == b % 2 { if a % 2 == 1 { a.cmp(&b) } else { b.cmp(&a) } } 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(); }