#P17222. [ICPC 2017 Nanning R] Twice Equation

    ID: 16785 Type: RemoteJudge 1000ms 512MiB Tried: 0 Accepted: 0 Difficulty: 6 Uploaded By: Tags>数学高精度2017二分ICPC

[ICPC 2017 Nanning R] Twice Equation

题目描述

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).

输入格式

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}).

输出格式

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

3
1
4
21
3
20
119