24 lines
324 B
Python
24 lines
324 B
Python
|
def g(n,start,a,b):
|
||
|
if sum(a)==n:
|
||
|
b.append(a[:])
|
||
|
return
|
||
|
|
||
|
for i in range(1,n+1):
|
||
|
if sum(a)+i>n:
|
||
|
break
|
||
|
a.append(i)
|
||
|
g(n,i,a,b)
|
||
|
a.pop()
|
||
|
|
||
|
def p(n):
|
||
|
b=[]
|
||
|
g(n,1,[],b)
|
||
|
b.sort()
|
||
|
for r in b:
|
||
|
print(" ".join(map(str,r)))
|
||
|
|
||
|
n=int(input())
|
||
|
p(n)
|
||
|
|
||
|
|