标签:turn bsp lse 优化 ret col leetcode solution 暴力
暴力会超时,利用二分优化。
class Solution { public: double myPow(double x, int n) { if (n<0){ x = 1/x; n = -n; } return pow(x,n); } double pow(double x, int n){ if (n==0) return 1.0; double half=pow(x,n/2); if (n%2==0) return half*half; else return half*half*x; } };
标签:turn bsp lse 优化 ret col leetcode solution 暴力
原文地址:https://www.cnblogs.com/hankunyan/p/9595502.html