Leetcode习题:Pow(x, n)
来源:互联网 发布:数据库垂直切分 编辑:程序博客网 时间:2024/06/14 18:05
Pow(x, n)
Total Accepted: 13567 Total Submissions: 52439Implement pow(x, n).
public class Solution { public double pow(double x, int n) { if(x == 0 || x == 1.0 || n == 1){ return x; }else if(n == 0){ return 1; } int absN = abs(n); double temp = pow(x, absN/2); double result = temp*temp; if(absN%2 != 0 ){ result *= x; } if(n<0){ return 1.0/result; }else{ return result; } } public int abs(int n ){ return n<0? -n:n; }}
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)
- LeetCode | Pow(x, n)
- Pow(x, n) -leetcode
- 【leetcode】Pow(x, n)
- 【Leetcode】Pow(x, n)
- LeetCode Pow(x, n)
- POJ 2559 Largest Rectangle in a Histogram(单调栈)
- Android系统SD驱动浅析
- java 邮件发送实现相关文章
- actionscript3.0 函数重载问题
- IOS的GCD
- Leetcode习题:Pow(x, n)
- Quartus II 13.1正式版(Windows版和Linux版破解)
- 字符串分割--java中String.split()用法
- 哎呀,sql语句记不清楚了。。。
- C/C++中int/long/float/double数值类型与字符串互相转换
- 点与园
- csu 1459: Chess (橡棋)
- java application中内嵌ActiveX控件
- POJ 2796 Feel Good(单调栈)