Sum of consecutive numbers
Time limit5sMemory limit256 MB
Write each N up to 1e9 as the shortest sum of two or more consecutive positive integers, or print IMPOSSIBLE.
- Level
Medium5 of 10
- Topics
- Math, Number theory
- Solved
- No attempts yet
Problem
Some numbers are a sum of two or more consecutive positive integers, and some numbers are not.
Given an integer , write as a sum of two or more consecutive positive integers. For example, and .
If several sums exist, print the one with the fewest terms. Once the number of terms is fixed the first term is fixed too, so the shortest sum is unique.
Input
The first line contains the number of test cases ().
Each of the next lines contains one integer ().
Output
Print one line for each test case. If the shortest sum runs from to , join all of its terms in this format.
N = a + (a+1) + ... + b
Put one space on each side of the equals sign and of every plus sign. If no such sum exists, print IMPOSSIBLE.