public static int sqrt(int x) {
    	if (0 == x) return 0;
    	long bit = 1l << 16;
    	long res = 0;
    	while (bit != 0) {
    		res = res | bit;
    		if (res * res > x) res = res ^ bit; 
    		bit = bit >> 1;
    	}
        return (int) res;
    }