剑指offer-数值的整数次方
来源:互联网 发布:数据库集群方案 编辑:程序博客网 时间:2024/06/07 05:11
public class Solution { final double INF = 0.00000000001; public double Power(double base, int exponent) { double res = 1.0; if(Math.abs(base-0.0) < INF) return 0.0; if(exponent==0) return 1; boolean isNegative = false; if(exponent < 0) isNegative = true; exponent = Math.abs(exponent); //System.out.println(exponent); res = fastConcluPower(base, exponent); if(isNegative) res = 1.0 / res; return res; } private double fastConcluPower(double base, int exponent) { System.out.println(base + " " + exponent); if(exponent == 0) return 1.0; int k = exponent / 2; double res = fastConcluPower(base, k); if((exponent&1)==1) return res * res * base; else return res * res; }}
阅读全文
0 0
- 剑指Offer之数值的整数次方
- 剑指offer:数值的整数次方
- 【剑指offer】数值的整数次方
- [剑指offer]Q11:数值的整数次方
- 【剑指offer】数值的整数次方
- 剑指Offer之数值的整数次方
- 《剑指offer》数值的整数次方
- 剑指offer--数值的整数次方
- 剑指Offer之 - 数值的整数次方
- 剑指offer-11 数值的整数次方
- 剑指offer 11 - 数值的整数次方
- 剑指Offer-数值的整数次方
- 剑指offer 数值的整数次方
- 《剑指offer》数值的整数次方
- 剑指offer—数值的整数次方
- 剑指Offer-11-数值的整数次方
- 【剑指offer】之数值的整数次方
- 剑指offer-数值的整数次方
- 25张图让你读懂神经网络架构
- 程序字符集问题
- rabbitmq(安装)
- 比特位操作——二进制表示
- CString分割切分 实现SplitCString
- 剑指offer-数值的整数次方
- Ubuntu 安装dbus-python 错误解决
- 内核同步机制
- POJ3660---Cow Contest(floyed传递闭包问题)
- 红黑树原理简析
- 表单数据验证
- 从互联网进化的角度看AI+时代的巨头竞争
- jsp——9大内置对象
- 输入域名到显示网页的网络过程