Problem
Input format
The program reads from standard input a single natural number, `n`. - `1 <= n <= 12` - A decomposition must have at least one term, so `n` itself is a valid decomposition (with a single term).
Output format
The program prints, one per line, all decompositions of `n` as a sum of strictly increasing positive integers. The terms of each decomposition are separated by spaces with no trailing space. Decompositions are printed in lexicographic order (those starting with smaller values come first). On the last line print the total number of decompositions.
Example
6
1 2 3 1 5 2 4 6 4
Stuck?
Use the Get Hint button in the action bar to reveal a guided hint.
💬 Discussion
Loading...No comments yet. Be the first to start the discussion!
Sample cases (from the problem)
Sample Case 1
6
1 2 3 1 5 2 4 6 4
Solve it your way first
Community solutions unlock after you submit a passing solution. Don't peek.
Ready to solve this challenge?
Create a free account to write code, submit solutions, and track your progress.