SP12721 PELL2 - Pell (Mid pelling)
Description
D is a given positive integer, consider the equation :
X² = D×Y² + 1, with X and Y positive integers.
Find the minimum numbers (X,Y) within all solutions.
Sometimes it's possible, sometimes not!
Examples :
If D=2, 3² = 2×2² + 1, so X=3 and Y=2.
If D=3, 2² = 3×1² + 1, so X=2 and Y=1.
If D=4, it's impossible!
Input Format
The input begins with the number T of test cases in a single line.
In each of the next T lines there is one integer D.
Output Format
For each test case, if possible print X and Y the answer of the problem for D, else "-1".
Explanation/Hint
T