eolymp
bolt
Try our new interface for solving problems
Problems

Partitions into summands

Partitions into summands

List all partitions of a positive integer \textbf{n} in terms of positive integers. Partition should have the following properties: \begin{itemize} \item Summands in partitions are in nonincreasing order. \item Partitions are listed in lexicographical order. \end{itemize} \InputFile Contains one integer \textbf{n} (\textbf{1} ≤ \textbf{n} ≤ \textbf{40}). \OutputFile Print the desired partitions one per line.
Time limit 1 second
Memory limit 128 MiB
Input example #1
4
Output example #1
1 1 1 1
2 1 1
2 2
3 1
4