#P8039. Consecutive Natural Numbers Sum

    ID: 21223 Type: Default 1000ms 256MiB

Consecutive Natural Numbers Sum

Consecutive Natural Numbers Sum

Given a positive integer \(N\), find all sequences of consecutive natural numbers with a length \(\geqslant 2\) that sum to \(N\). For example, if \(N = 9\), there are two sequences: \(2+3+4=9\) and \(4+5=9\).

You are required to output the number of valid sequences on the first line, followed by each sequence on a new line with the numbers separated by a single space. If no sequence exists, output 0.

inputFormat

The input consists of a single positive integer \(N\).

outputFormat

Output the count of consecutive number sequences found in the first line. Then, for each sequence, output the sequence on a separate line with its numbers separated by spaces. If there is no valid sequence, output 0.

sample

9
2

2 3 4 4 5

</p>