b = [0, 1] for i in range(16): b += [i+1 for i in b] def mb(t): s = 0 for i in t: s+= b[i] return s def next(t): n = len(t) if t[n-1]!=1: t.append(1) return t else: t[n-1] += 1 while(n>1): if t[n-1]==t[n-2]: t[n-2] += 1 n -= 1 t=t[:n] else: break return t c = [1] k = int(input()) while mb(c)!=k: c = next(c) print(len(c)) print(" ".join([str(j) for j in c]))
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | b = [0, 1] for i in range(16): b += [i+1 for i in b] def mb(t): s = 0 for i in t: s+= b[i] return s def next(t): n = len(t) if t[n-1]!=1: t.append(1) return t else: t[n-1] += 1 while(n>1): if t[n-1]==t[n-2]: t[n-2] += 1 n -= 1 t=t[:n] else: break return t c = [1] k = int(input()) while mb(c)!=k: c = next(c) print(len(c)) print(" ".join([str(j) for j in c])) |