P1147 Sum of Consecutive Positive Integers

Description

Given a positive integer $M$, find all segments of consecutive positive integers (each segment must contain at least two numbers) whose sum is $M$. Example: $1998+1999+2000+2001+2002 = 10000$, so the segment from $1998$ to $2002$ is a solution for $M=10000$.

Input Format

A single line containing an integer giving the value of $M$ ($10 \le M \le 2,000,000$).

Output Format

Output one line per solution, containing two positive integers: the first and last numbers of a valid consecutive positive integer segment, separated by a space. Sort all lines by the first number in ascending order. For the given input, at least one solution exists.

Explanation/Hint

Translated by ChatGPT 5