/home/toolbox/public_html/solutions/100/10023/10023.java
1 import java.util.Scanner;
2 import java.math.BigInteger;
3
4 class Main
5 {
6 public static void main(String args[])
7 {
8
9 int num;
10 BigInteger x;
11 BigInteger bottom;
12 BigInteger top;
13 BigInteger y;
14 BigInteger tmp;
15 BigInteger one = new BigInteger("1");
16 BigInteger two = new BigInteger("2");
17
18 Scanner sc = new Scanner(System.in);
19 num = sc.nextInt();
20 for (int i=0; num>i; i++)
21 {
22 // for each input
23 if (0 != i) System.out.println();
24 x = sc.nextBigInteger();
25 bottom = one;
26 top = x;
27 y = (bottom.add(top)).divide(two);
28 tmp = y.multiply(y);
29 while (0 != tmp.compareTo(x))
30 {
31 if (0 > tmp.compareTo(x))
32 bottom = y;
33 else
34 top = y;
35 y = (bottom.add(top)).divide(two);
36 tmp = y.multiply(y);
37 }
38
39 System.out.println(y);
40 }
41 }
42 }
43