#B2133. House Number Puzzle
House Number Puzzle
House Number Puzzle
You live in a short alley where the houses are numbered sequentially starting from \(1\). The twist is that if the sum of all the other houses' numbers minus twice your house number equals \(n\), you need to determine your house number and the total number of houses in the alley.
Let \(m\) be the total number of houses and \(k\) be your house number. The sum of the house numbers from \(1\) to \(m\) is given by \(S = \frac{m(m+1)}{2}\). Excluding your house, the sum becomes \(S - k\). According to the problem,
[ (S - k) - 2k = n \quad \Longrightarrow \quad S - 3k = n ]
Your task is to find the unique pair \((k, m)\) that satisfies the equation:
[ \frac{m(m+1)}{2} - 3k = n ]
It is guaranteed that a unique solution exists.
inputFormat
The input consists of a single integer \(n\) (\(n\) can be negative, zero, or positive).
outputFormat
Output two integers separated by a space: your house number \(k\) and the total number of houses \(m\).
sample
0
2 3