当前位置:网站首页>Sword finger offer 16 Integer power of numeric value
Sword finger offer 16 Integer power of numeric value
2022-06-30 18:28:00 【anieoo】
Original link : The finger of the sword Offer 16. Integer power of value
solution:
Fast power
① Calculation x Of n To the power of n individual x multiply continuously , Low efficiency , Will timeout .
② Multiplication has the law of association , It is considered to calculate a part of the serial multiplication batch each time , As part of the final answer .
class Solution {
public:
typedef long long LL;
double myPow(double x, int n) {
bool is_minus = n < 0;
double res = 1;
for(LL k = abs(n);k;k >>= 1) {
if(k & 1) res *= x;
x *= x;
}
if(is_minus) return 1 / res;
return res;
}
};边栏推荐
- NFT: 开启加密艺术时代的无限可能
- 力扣解法汇总1175-质数排列
- TiDB Dashboard里面可以写sql执行吗
- 基于SSM的新闻管理系统
- In distributed scenarios, do you know how to generate unique IDs?
- What did Tongji and Ali study in the CVPR 2022 best student thesis award? This is an interpretation of yizuo
- VScode 状态条 StatusBar
- Post MSF infiltration summary
- C language structure
- DeFi借贷协议机制对比:Euler、Compound、Aave和Rari Capital
猜你喜欢

漏洞复现----35、uWSGI PHP 目录遍历漏洞 (CVE-2018-7490)

New research of HKUST & MsrA: about image to image conversion, finishing is all you need

MySQL advanced - index optimization (super detailed)

剑指 Offer 17. 打印从1到最大的n位数

Helping the ultimate experience, best practice of volcano engine edge computing

每日面试1题-蓝队基础面试题-应急响应(1)应急响应基本思路流程+Windows入侵排查思路

Type ~ storage ~ variable in C #

In distributed scenarios, do you know how to generate unique IDs?

后渗透之文件系统+上传下载文件

News management system based on SSM
随机推荐
C语言结构体
基于eNSP的校园网设计的仿真模拟
Deep understanding of JVM (I) - memory structure (I)
Techo Youth2022学年高校公开课:直播连麦的背后,探索音视频技术如何应用
Daily interview 1 question - basic interview question of blue team - emergency response (1) basic idea process of emergency response +windows intrusion screening idea
云安全日报220630:IBM数据保护平台发现执行任意代码漏洞,需要尽快升级
Simulation of campus network design based on ENSP
基于SSH的客户关系CRM管理系统
LeetCode之合并二叉树
Deep understanding of JVM (VI) -- garbage collection (III)
What will be the game changes brought about by the meta universe?
[machine learning] K-means clustering analysis
助力极致体验,火山引擎边缘计算最佳实践
Rhai 脚本引擎的简单应用示例
Redis (VII) - sentry
MIT science and Technology Review released the list of innovators under the age of 35 in 2022, including alphafold authors, etc
Ardunio esp32 obtains real-time temperature and humidity in mqtt protocol (DH11)
What does software testing need to learn? Test learning outline sorting
Hcip (Huawei Senior Network Security Engineer) (Experiment 8) (MPLS basic experiment)
What did Tongji and Ali study in the CVPR 2022 best student thesis award? This is an interpretation of yizuo