leetcode 050 Pow(x, n)
来源:互联网 发布:大数据运用案例 编辑:程序博客网 时间:2024/05/17 06:39
Implement pow(x, n).Subscribe to see which companies asked this question
class Solution {public: double myPow(double x, int n) { double ans = 1.0;double temp = x;bool flag = false;long long cnt = n;if(cnt == 0) return 1.0;if(cnt < 0) {flag = true;cnt = -cnt;}while(cnt > 0) {if(cnt & 1) {ans *= temp;}temp *= temp;cnt = cnt >> 1;}return flag==true?1.0/ans:ans; }};
0 0
- LeetCode 050 pow(x,n)
- LeetCode 050 Pow(x, n)
- LeetCode 050 Pow(x, n)
- leetcode 050 Pow(x, n)
- [LeetCode]050-Pow(x,n)
- LeetCode 050 Pow(x, n)
- LeetCode 050 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)
- nginx反向代理
- js自娱自乐
- AngularJS五特性
- SWT编程基础-Display和Shell
- php中构造函数和析构函数
- leetcode 050 Pow(x, n)
- JDBC CRUD操作
- 设计模式六大原则(6):开闭原则
- DRP总结—JSP+Servlet+JSTL简单介绍
- Windbg、dump分析类资源链接
- ftp上传文件
- Android群英传笔记——第十二章:Android5.X 新特性详解,Material Design UI的新体验
- Ubuntu14.04下安装DOC++
- libpcap使用