Implement pow(x, n).
思路:二分法,将每次相乘,转化成平方。
class Solution {
public:
double myPow(double x, int n) {
if(n==) {
return ;
} double result = myPow(x, n/);
result*= result;
if(n%==) result = x * result;
else if(n%==-) result = (/x) * result; //negative number
return result;
}
};