当前位置:网站首页>Fast power (template)
Fast power (template)
2022-07-04 06:02:00 【Zheng Qingda doesn't know his name】
Fast power ( Templates )
Time complexity O(logn);
Spatial complexity O(1);
double myPow(double x, int n) {
if(n==0) return 1;
double sum=1;
long long m=abs(n);//long long Type prevents n=-2^31 Take the timing and burst it int;
while(m) {
if(m&1) {
if(n>0) sum*=x;
else sum/=x;
}
m>>=1;
x*=x;
}
return sum;
}
边栏推荐
- C language exercises (recursion)
- 70000 words of detailed explanation of the whole process of pad openvino [CPU] - from environment configuration to model deployment
- tutle时钟改进版
- 报错cvc-complex-type.2.4.a: 发现了以元素 ‘base-extension‘ 开头的无效内容。应以 ‘{layoutlib}‘ 之一开头。
- How to expand all collapse panels
- C语言练习题(递归)
- buuctf-pwn write-ups (8)
- [microservice] Nacos cluster building and loading file configuration
- Detailed explanation of common APIs for component and container containers: frame, panel, scrollpane
- Luogu deep foundation part 1 Introduction to language Chapter 5 array and data batch storage
猜你喜欢
Compound nonlinear feedback control (2)
测试岗的中年危机该如何选择?是坚守还是另寻出路?且看下文
HMS v1.0 appointment.php editid参数 SQL注入漏洞(CVE-2022-25491)
Leetcode question brushing record | 206_ Reverse linked list
Online shrimp music will be closed in January next year. Netizens call No
How to get the parent node of all nodes in El tree
BUU-Crypto-Cipher
How does apscheduler set tasks not to be concurrent (that is, execute the next task after the first one)?
报错cvc-complex-type.2.4.a: 发现了以元素 ‘base-extension‘ 开头的无效内容。应以 ‘{layoutlib}‘ 之一开头。
Sword finger offer II 038 Daily temperature
随机推荐
体验碎周报第 102 期(2022.7.4)
【无标题】
tutle时钟改进版
Arc135 C (the proof is not very clear)
JS扁平化数形结构的数组
AWT introduction
Accidentally deleted the data file of Clickhouse, can it be restored?
1480. Dynamic sum of one-dimensional array
js如何将秒转换成时分秒显示
724. Find the central subscript of the array
Understanding of cross domain and how to solve cross domain problems
How to solve the component conflicts caused by scrollbars in GridView
Notes and notes
Grounding relay dd-1/60
Luogu deep foundation part 1 Introduction to language Chapter 5 array and data batch storage
APScheduler如何设置任务不并发(即第一个任务执行完再执行下一个)?
Steady! Huawei micro certification Huawei cloud computing service practice is stable!
Design and implementation of redis 7.0 multi part AOF
left_and_right_net可解释性设计
el-select如何实现懒加载(带搜索功能)