#K34132. Longest Consecutive Sum Sequence

    ID: 25242 Type: Default 1000ms 256MiB

Longest Consecutive Sum Sequence

Longest Consecutive Sum Sequence

Given a target integer \(T\), find the longest sequence of consecutive positive integers such that their sum equals \(T\). If there are multiple sequences of the same maximum length, return any one of them. If no such sequence exists (for example, when \(T \le 0\)), output an empty result.

The sum \(S\) of a sequence starting from \(a\) with \(n\) consecutive numbers is given by the formula:

S=n2(2a+n1)S = \frac{n}{2} (2a + n - 1)

Your task is to determine the sequence with maximum length that satisfies \(S = T\).

inputFormat

The input is provided through standard input. The first and only line contains a single integer \(T\), representing the target sum.

outputFormat

Print the sequence of consecutive integers that sums to \(T\) on a single line, with each number separated by a space. If no valid sequence exists, output an empty line.

## sample
15
1 2 3 4 5

</p>