#P1147. Continuous Natural Number Subsequences Summing to M

    ID: 13552 Type: Default 1000ms 256MiB

Continuous Natural Number Subsequences Summing to M

Continuous Natural Number Subsequences Summing to M

Given a positive integer (M), find all segments of consecutive natural numbers (each segment contains at least two numbers) such that the sum of the numbers in the segment is exactly (M).

For example, since (1998+1999+2000+2001+2002 = 10000), the segment from (1998) to (2002) is a valid solution when (M = 10000).

Please output each valid segment on a separate line, with the numbers separated by a single space. The segments should be presented in increasing order of their first number. If no segment exists, output the string NONE.

inputFormat

The input consists of a single positive integer (M) ((1 \le M \le 10^9)).

outputFormat

For each valid segment, output a line containing the consecutive natural numbers separated by a space. If there are multiple segments, output each on a new line in increasing order of the first number. If no valid segment exists, output NONE.

sample

3
1 2