#P1147. 连续自然数和

连续自然数和

Description

Given a positive integer MM, find all segments of consecutive positive integers (each segment must contain at least two numbers) whose sum is MM.

Example: 1998+1999+2000+2001+2002=100001998+1999+2000+2001+2002 = 10000, so the segment from 19981998 to 20022002 is a solution for M=10000M=10000.

Input Format

A single line containing an integer giving the value of MM (10M2,000,00010 \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.

10000

18 142 
297 328 
388 412 
1998 2002

Hint

Translated by ChatGPT 5