#include #define MAX 1073741823 using namespace std; int K; int num[31] = {0}; int dp[31][3]; int Combi(int n, int r){ if(n == r) return dp[n][r] = 1; if(r == 0) return dp[n][r] = 1; if(r == 1) return dp[n][r] = n; if(dp[n][r]) return dp[n][r]; return dp[n][r] = Combi(n - 1, r) + Combi(n - 1, r - 1); } void rec(int zero = 0, int one = 0, int count = 0){ int c = (one >= 2) ? Combi(one, 2) : 0; int p = pow(2, zero); if(count > 30) return; if(c * p > K) return; if(c * p == K){ cout << count << endl; for(int i = 0; i < count; ++i){ cout << num[i]; if(i != count - 1) cout << " "; } cout << endl; exit(0); } num[count] = 0; rec(zero + 1, one, count + 1); num[count] = 1; rec(zero, one + 1, count + 1); return; } int main(void){ cin >> K; if(K == 0) cout << 0 << endl << endl; else rec(); return 0; }