Import Java. io. bufferedinputstream; import Java. math. biginteger; import Java. util. extends; public class main {public static biginteger p, q; public static void solve (int n) {biginteger N, P1, P2, Q1, q2, A0, A1, A2, g1, G2, H1, H2; P1 = biginteger. zero; P2 = biginteger. one; Q1 = P2; Q2 = p1; a0 = A1 = biginteger. valueof (long) math. SQRT (1.0 * n); G1 = p1; H1 = P2; n = biginteger. valueof (n); While (true) {g2 = A1.multiply (H1 ). subtract (G1); H2 = n. subtract (g2.pow (2 )). divide (H1); a2 = g2.add (A0 ). divide (H2); P = a1.multiply (P2 ). add (P1); q = a1.multiply (Q2 ). add (Q1); If (P. pow (2 ). subtract (N. multiply (Q. pow (2 ))). compareto (biginteger. one) = 0) {return;} G1 = G2; H1 = h2; a1 = a2; P1 = P2; P2 = P; Q1 = Q2; Q2 = Q ;}} public static void main (string [] ARGs) {partition CIN = new partition (New bufferedinputstream (system. in); int N, Temp; while (CIN. hasnext () {n = cin. nextint (); temp = (INT) math. SQRT (N * 1.0); If (temp * temp = N) {system. out. println ("no solution! "); Continue;} solve (n); system. Out. println (p +" "+ q );}}}