LeetCode-Pow(x, n)
来源:互联网 发布:win10新系统优化 编辑:程序博客网 时间:2024/06/08 07:36
Implement pow(x, n).
double searcht(double x,int m);double output = 1;class Solution {public: double pow(double x, int n);};//不知道采用迭代算法怎么样double Solution::pow(double x, int n){ int signal = 0; if(n == 0) return 1; if(n == -2147483648) { n = 2147483647; searcht(x,n); return 1/(output*x); } if(n < 0) { n = -n; signal = 1; } searcht(x,n); if(signal == 1) return 1/output; else return output;};double searcht(double x,int m){ if(m == 1) {output = x; return 1;} if(m%2 == 0) { searcht(x,m/2); output = output *output; } else { searcht(x,m/2); output = output*output*x; }};
0 0
- LeetCode: Pow(x, n)
- LeetCode Pow(x,n)
- [Leetcode] Pow(x, n)
- LeetCode: Pow(x, n)
- Leetcode: Pow(x,n)
- [LeetCode] Pow(x, n)
- [Leetcode] Pow(x,n)
- 【leetcode】Pow(x, n)
- [LeetCode]Pow(x, n)
- [leetcode]Pow(x, n)
- LeetCode-Pow(x, n)
- LeetCode - Pow(x, n)
- LeetCode | Pow(x, n)
- Pow(x, n) -leetcode
- 【leetcode】Pow(x, n)
- 【Leetcode】Pow(x, n)
- LeetCode Pow(x, n)
- Leetcode: Pow(x, n)
- Nginx日志log
- leetcode Container With Most Water
- spring中的get和set方法
- iOS开发navigationBar导航条和navigationItem设置:基本搞定导航条上的文字和按钮以及各种跳转
- HEVC—参数GOP,SLICE,TILE解疑
- LeetCode-Pow(x, n)
- Python标准库:内置函数globals()
- 【UML】概念、关系、图(二)
- Xcode6小技巧-#pragma-mark对函数进行分类
- 军训报数(哈希+素数判断+状态压缩)
- 管理启动项 - Windows 7中的BCDEDIT命令
- Unable to execute dex: Multiple dex files define.... ...Conversion to Dalvik format failed: Unable t
- 算法的时间复杂度
- NSString和NSMutableString的基本应用