2023-2024 ICPC, Swiss Subregional |
---|
Finished |
Tony and Ben are two classmates who typically get very bored throughout their summer vacation. To cure their boredom, they always try out the silliest games they can come up with. The latest one they played involved choosing a positive integer and calculating the sum of all the terms from $$$1$$$ up to that integer.
Tony calculated the sum of integers from $$$1$$$ to $$$n$$$ ($$$1 + 2 + \dots + n$$$), while Ben computed the sum of integers from $$$1$$$ to $$$m$$$ ($$$1 + 2 + \dots + m$$$).
A few days later, the two boys recalled their game, but they could no longer remember the values of $$$n$$$ and $$$m$$$, only the difference $$$d$$$ between the two sums they had initially obtained. They also recall that $$$m$$$ was larger than $$$n$$$.
For a given value of $$$d$$$, find all pairs $$$(n, m)$$$.
The only line of input contains the integer $$$d$$$ ($$$2 \leq d \leq 10^{12}$$$).
In the first line print integer $$$s$$$ — the number of pairs. In the next $$$s$$$ lines print all pairs $$$(n,m)$$$. You may print the pairs in any order. Each pair must be printed exactly once, and $$$m > n$$$ must hold for all pairs.
Under given constraints, it can be proven that $$$ 1 \leq s \leq 10^4$$$.
5
2 4 5 1 3
9
3 8 9 3 5 1 4
Name |
---|