** 题目描述:**
实现 [pow(x, n)],即计算 x 的 n 次幂函数。

思路:
采用分治的思想,将n次幂转为n/2, n/4,...,1 or 0次幂。
其中要注意当n为Integer.MIN_VALUE时,要特殊处理,因为此时-n会溢出。

这里有关int类型表示范围及解释,参见这篇文章:
https://www.jianshu.com/p/c0ceaa7be812

class Solution {
    public double myPow(double x, int n) {
        if(n==0)
            return 1;
        if(n==1)
            return x;
        if(n<0){
            if(n==Integer.MIN_VALUE){
                ++n;
                return 1/(myPow(x,-n)*x);
            }else{
                return 1/myPow(x,-n);    
            }
            
        }
        if(n%2==0){
            double y = myPow(x,n/2);
            return y*y;
        }
        else{
            return myPow(x,n-1)*x;
            
        }
    }
}