Pow(x, n)

这个注意负数的情况, 用二分做.

public class Solution {
    public double myPow(double x, int n) {
        if(n == 0)
            return 1;
        if(n == 1)
            return x;
        boolean neg = false;
        if(n < 0){
            neg = true;
            n = -n;
        }
        int k = n / 2;
        int l = n - k * 2;
        
        double t1 = myPow(x,k);
        double t2 = myPow(x,l);
        
        if(neg)
            return 1/(t1*t1*t2);
        else
            return t1*t1*t2;
        
    }
}