Inverse triangular numbers#6008

Inverse triangular numbers

1 second
128 megabytes
Easy

A triangular number is a number that can be represented as a set of points arranged in an equilateral triangle with points on each side. Below are several examples of such triangles and their corresponding triangular numbers:

It is easy to see that a triangular number is an additive analogue of the factorial:

T_n = \sum_{k = 1}^n k

Given an integer , determine whether it is a triangular number. If the number is triangular, you must also determine the number of points on each side of the corresponding triangle.

For example, if n = 10, the program should report that this is a triangular number with points on each side, since

10 = 4 + 3 + 2 + 1

If n = 11, the program should report that it is not a triangular number.

Input

Each line contains one integer n~(0 < n < 10^9). The last line contains and should not be processed.

Output

For each value of , determine whether it is a triangular number. If it is, print the number of points on a side on a separate line. Otherwise, print the string "bad".

Examples

Example 1

Loading
Loading