fun main() { val n = readLine()!!.toInt() val sqrtn = Math.sqrt(n.toDouble()).toInt() val dp = Array(sqrtn){Array(n+1){it}} val memo = Array(sqrtn){Array(n+1){it}} for(i in 1 until sqrtn)for(j in 0 until n+1){ dp[i][j] = 100000//inf var count = 0 for(k in j downTo 0 step (i+1)*(i+1)){ if(dp[i-1][k]+i*count() var l = n for(i in sqrtn - 1 downTo 0){ for(j in 0 until memo[i][l]){ ansList += i+1 l-=(i+1)*(i+1) } } var ans = ansList.filter{it%2==1}.asReversed().toMutableList() val even = ansList.filter{it%2==0} ans = ans.plus(Array(even.count()){ if(it%2==0)even[it/2] else even[even.count()-(it+1)/2] }).toMutableList() println(ans) var suf = 0 for(i in ans){ for(j in 0 until i){ print(suf) suf=rev(suf) } suf=rev(suf) } println("") } fun rev(suf:Int)=if(suf==0)1 else 0