SP12721 PELL2 - Pell (Mid pelling)

题目描述

给定 $d$,求方程 $x^2=dy^2+1$ 的最小正整数解。 请注意,方程可能有解,也可能无解。 例如: 当 $d=2$ 时,$3^2= 2 \times 2^2+ 1$,有解 $x = 3$ 和 $y = 2$。 当 $d=3$ 时,$2^2= 3 \times 1^2+ 1$,有解 $x = 2$ 和 $y = 1$。 当 $d=4$ 时,无解。

输入格式

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.

输出格式

For each test case, if possible print X and Y the answer of the problem for D, else "-1".

说明/提示

T