leetcode 50. Pow(x, n)
来源:互联网 发布:苹果手机 软件检测 编辑:程序博客网 时间:2024/04/27 22:46
50. Pow(x, n)
Implement pow(x, n).
Example 1:
Input: 2.00000, 10Output: 1024.00000
Example 2:
Input: 2.10000, 3Output: 9.26100
class Solution {public: double myPow(double x, int n) { long nn = n; if(nn == 0) return 1; else if(x == 1) return x; else if(x==-1) return ( n % 2 == 0) ? 1 : -1; else if(nn < 0) { x = 1 / x; nn = -nn; } double sum = 1.00000; for (long i = 1; i <= nn; i++) { sum = sum * x; if(abs(sum) < 0.000000001) return 0.00000; } return sum; }};
阅读全文
0 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)
- 50. Pow(x, n) LeetCode
- [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)
- LeetCode - 50. Pow(x, n)
- [LeetCode] 50. Pow(x, n)
- LeetCode 50. Pow(x, n)
- 利用Centos 7内置的 crontab 进行系统的定时关机 格式: * * * * * command 分 时 日 月 周 命令 1 2 3 #编辑定时任务: crontab -e
- 【Unity】模型烘培参数
- Java并发之AQS详解
- 设计模式:单例模式
- Automotive radar 信号处理 第3课 方位估计
- leetcode 50. Pow(x, n)
- 电子转战AI
- 浅析C# new和override的区别
- AndroidStudio填坑
- Ubuntu16.04下安装Caffe记录(GPU)
- ACCESS 复制文件
- 第四章 SpringMVC--Controller接口控制器详解
- C++学习记录20--endl,'\n',"\n"
- 各邮箱的邮件接收服务器和发送服务器