#26392. 连续正整数和

    ID: 26392 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>数学枚举前缀和双指针 two-pointer

连续正整数和

Problem 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