Leetcode 50 Pow(x, n)
来源:互联网 发布:英语语法书籍 知乎 编辑:程序博客网 时间:2024/06/05 05:17
Implement pow(x, n).
快速幂,要注意n为INT_MIN和负数的情况,细碎小恶魔
class Solution {public: double myPow(double x, long long n) { double result=1,base=x; while(n) { if(n<0) { base=1/base; n=-n; } if(n&1) result*=base; base*=base; n>>=1; } return result; }};
1 0
- leetcode 50 : Pow(x, n)
- LeetCode 50: Pow(x, n)
- [leetcode 50] Pow(x, n)
- [Leetcode] 50 - Pow(x, n)
- [LeetCode 50]Pow(x, n)
- leetcode 50 Pow(x, n)
- leetcode || 50、Pow(x, n)
- [leetcode] #50 Pow(x,n)
- LeetCode-50 Pow(x, n)
- Pow(x, n) - LeetCode 50
- Leetcode(50):Pow(x, n)
- LeetCode---(50)Pow(x, n)
- Leetcode #50 Pow(x, n)
- LeetCode(50) Pow(x, n)
- leetcode 50: Pow(x, n)
- Leetcode#50||Pow (x, n)
- [Leetcode]#50 Pow(x, n)
- leetcode 50:Pow(x, n)
- unix&linux-redirect
- maven构建不同配置文件的安装包
- Spring---ApplicationContext的事件机制
- 读STM32F4xx中文参考手册笔记(四)
- 学会调试
- Leetcode 50 Pow(x, n)
- Hrbust 1355 Leyni,罗莉和XianGe (最短路 思维建图,dij优化)
- 【webpack】学习记录(一)
- fnmatch实例详解
- unix&linux 经常使用的命令
- ResultSet的getDate()、getTime()和getTimestamp()比较
- NYOJ995-经典DP
- 常用排序算法的性能分析及应用场景
- 聊聊并发(1):深入分析Volatile的实现原理