n=int(input()) x=0 i=0 list=[] list.append(0) while x<n: i+=1 maska=1 ile=x while maska<=i: if maska&i: x+=1 maska<<=1 list.append(x-ile) ile=i licz=i w="" while x>n: if x-list[i-1]>=n: x-=list[i-1] list[i-1]=0 ile-=1 i-=1 print(ile) for i in range(licz,1,-1): if list[i]: w+=str(i)+' '; print(w,1)
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 | n=int(input()) x=0 i=0 list=[] list.append(0) while x<n: i+=1 maska=1 ile=x while maska<=i: if maska&i: x+=1 maska<<=1 list.append(x-ile) ile=i licz=i w="" while x>n: if x-list[i-1]>=n: x-=list[i-1] list[i-1]=0 ile-=1 i-=1 print(ile) for i in range(licz,1,-1): if list[i]: w+=str(i)+' '; print(w,1) |