#P17222. [ICPC 2017 Nanning R] Twice Equation

    ID: 19647 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度普及+/提高− 上传者: 标签>数学高精度2017二分ICPC

[ICPC 2017 Nanning R] Twice Equation

Problem Description

For given LL, find the smallest nn no smaller than LL for which there exists an positive integer mm for which 2m(m+1)=n(n+1)2m(m + 1) = n(n + 1).

Input Format

This problem contains multiple test cases. The first line of a multiple input is an integer T(1≤T<1000)T (1 \le T < 1000) followed by TT input lines. Each line contains an integer L(1≤L<10190)L (1 \le L < 10^{190}).

Output Format

For each given LL, output the smallest nn. If available nn does not exist, output −1-1.

3
1
4
21
3
20
119