[leetcode]50. Pow(x, n)
来源:互联网 发布:淘宝人群画像分析 编辑:程序博客网 时间:2024/06/10 20:20
题目链接:https://leetcode.com/problems/powx-n/#/description
Implement pow(x, n).
class Solution {public: double myPow(double x, int n) { if (n == 0) return 1.0; else { if (n < 0) { //判断是否溢出 if (n == INT_MIN) return 1.0 / (myPow(x, INT_MAX)*x); else return 1.0 / myPow(x, -n); }else{ if (n % 2 == 0) { double temp = myPow(x, n >> 1); return temp * temp; } else{ double temp = myPow(x, (n - 1) >> 1); return temp * temp * x; } }//else }//else }};
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)
- 有关git中.ignore的创建(方法一)
- vue学习笔记
- AAPT err(Facade for): libpng error: Not a PNG file 错误解决
- shared_ptr,weak_ptr,unique_ptr
- LINK : fatal error LNK1104: 无法打开文件“kernel32.lib”
- [leetcode]50. Pow(x, n)
- 【Maven】maven打包生成可执行jar文件
- TCP、UDP 发送、接收0字节问题
- 前端必须掌握30个CSS3选择器
- java包的定义与使用
- mybatis使用注解编写crud后,不配置mapping方法。
- Spinner 实现key value 效果
- Tensorflow报错:AttributeError: 'module' object has no attribute 'summary'
- B树的插入