[leetCode] Pow(x,n)(分治)
来源:互联网 发布:开淘宝网店一件代发 编辑:程序博客网 时间:2024/05/15 05:07
“`
double myPow2(double x, int n) {
double tmp;
if(n==1)
return x;
tmp=myPow2(x,n/2);
if(n%2==1) //奇数
return x*tmp*tmp;
else
return tmp*tmp;
}
double myPow(double x, int n) {
if(x==1.0) return x;
if(x==-1.0) return n%2==1?x:-x;
if(n==0) return 1;
if(n>0)
return myPow2(x,n);
if(n<0) return 1/myPow2(x,-n);
}“`
0 0
- [leetCode] Pow(x,n)(分治)
- LeetCode Pow(x,n)(分治法)
- LeetCode 之 Pow(x, n)(分治法)
- [leetcode] 【分治法】 50. Pow(x, n)
- 50. Pow(x, n)(分治)
- [算法作业][LeetCode] 50. 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)
- Swift项目兼容Objective-c问题汇总
- poj 2632Crashing Robots 暑假第8题 大模拟,水题
- IOS SEL (@selector) 原理及使用总结(一)
- one recursive approach for 3, hdu 1016 (with an improved version) , permutations, N-Queens puzzle
- 杭电 hdu 1856 More is better (并查集)
- [leetCode] Pow(x,n)(分治)
- 【安卓基础一】安卓架构、Dalvik VM、apk与.dex
- DataGrid- formatter:formatOper方法不可用
- 我的Android进阶之旅------>Android SDK支持的配置标识符(有用的参考文件)
- IOS SEL (@selector) 原理及使用总结(二)
- 个人对opencv在不同使用环境下要编译的理解
- hdu 1020 Encoding
- 深刻理解Linux进程间通信(IPC)
- pat 1041. Be Unique (20)