In a three-hole exhibition round, a golfer's score relative to par on each hole is recorded as an integer — negative for under par, positive for over par, zero for even par. The tournament organizer wants the three holes' relative scores, taken in increasing order, to be three consecutive integers on the number line (for example -1, 0, 1) whose total equals a fixed target sum. Given the target sum, determine the three consecutive integers, listed from smallest to largest, that add up to it. If no three consecutive integers sum to the target, report that it is impossible.
A single line containing one integer T, the target sum.
If there exist three consecutive integers x-1, x, x+1 whose sum equals T, print them separated by single spaces, smallest first. Otherwise, print exactly IMPOSSIBLE.
Example 1
Input
33
Expected
10 11 12
Explanation
The three consecutive integers 10, 11, 12 sum to 33 (3 times the middle value 11 equals 33), so they are printed smallest first.
Example 2
Input
4
Expected
IMPOSSIBLE
Explanation
The sum of any three consecutive integers x-1, x, x+1 always equals 3x, a multiple of 3. Since 4 is not a multiple of 3, no such triple exists, so the output is IMPOSSIBLE.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →