pow(x,n)
来源:互联网 发布:足球 数据 编辑:程序博客网 时间:2024/06/18 14:09
快速幂算法
注意要处理 INT_MIN的情况
class Solution {public: double myPow(double x, int n) { if(n<0) { if(n==INT_MIN) return 1.0/ ( myPow(x,INT_MAX)*x); //be carefully... INT_MIN=-INT_MAX-1; else return 1.0/ myPow(x,-n); } if(n==0) return 1.0; double ans=1.0; for(;n;x*=x,n>>=1) { if(n&1) ans*=x; } return ans; }};
0 0
- Pow(x, n) / Super Pow
- 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】Pow(x, n)
- Pow(x, n)
- 求 pow(x, n)
- [LeetCode]Pow(x, n)
- Pow(x,n)
- Pow(x, n)
- Pow(x, n)
- [leetcode]Pow(x, n)
- LeetCode-Pow(x, n)
- 取消tableviewcell选中效果
- Charles抓包使用教程
- Android 五大布局
- MySQL中TPS和QPS的计算方式
- linux访问windows共享文件夹的两种方法
- pow(x,n)
- Leetcode Minimum Height Trees
- 死刑犯和CEO写给母亲的信,价值上亿!惊醒无数父母!
- Android开发之内存管理
- Using the iPod Library
- 大型分布式网站架构
- 开源项目 FDTemplateLayoutCell研究
- 蓝桥杯 2015校内选拔试题 第四题:数字与文字
- css定宽块级元素居中