#P8039. [COCI 2016/2017 #7] UZASTOPNI
[COCI 2016/2017 #7] UZASTOPNI
Background
The only differences between this problem and P1147 are the range of the sum of consecutive natural numbers and the output format.
Problem Description
Find all consecutive segments of natural numbers with length whose sum is .
Input Format
The input contains only one line with an integer , which represents the sum of the consecutive natural number segment.
Output Format
Output several lines. Each line contains two integers, representing the first number and the last number of a valid consecutive natural number segment, sorted in descending order by the first number.
For the given input, it is guaranteed that there is at least one solution.
10
1 4
27
13 14
8 10
2 7
Hint
[Sample 1 Explanation]
. We can see that there is one and only one consecutive natural number segment whose sum is and satisfies the requirements.
[Constraints]
For all testdata, .
[Source]
This problem is from COCI 2016-2017 CONTEST 7 T2 UZASTOPNI. With the original problem's data settings, the full score is points.
Translated and organized by Eason_AC.
Translated by ChatGPT 5