Magic constant
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Let k be the magic constant for number n, if 1 + 2 + 3 + . . . + (k - 1) + k = n. Your task is to find the magic constant for a given number.
Input
One number n (1 ≤ n ≤ 10^18
).
Output
Print the magic constant for number n, if it exists and -1 otherwise.
Examples
Input #1
Answer #1
Input #2
Answer #2
Submissions 2K
Acceptance rate 29%