当前位置:网站首页>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;
}
边栏推荐
- Grounding relay dd-1/60
- Online shrimp music will be closed in January next year. Netizens call No
- 复合非线性反馈控制(二)
- Invalid revision: 3.18.1-g262b901-dirty
- HMS v1.0 appointment.php editid参数 SQL注入漏洞(CVE-2022-25491)
- How to solve the component conflicts caused by scrollbars in GridView
- 安装 Pytorch geometric
- Detectron: train your own data set -- convert your own data format to coco format
- Kubernets first meeting
- Win10 clear quick access - leave no trace
猜你喜欢
Gridview出现滚动条,组件冲突,如何解决
HMS v1.0 appointment.php editid参数 SQL注入漏洞(CVE-2022-25491)
ES6 modularization
Accidentally deleted the data file of Clickhouse, can it be restored?
509. 斐波那契数、爬楼梯所有路径、爬楼梯最小花费
buuctf-pwn write-ups (8)
JS arguments parameter usage and explanation
Yiwen unlocks Huawei's new cloud skills - the whole process of aiot development [device access - ESP end-to-side data collection [mqtt]- real time data analysis] (step-by-step screenshot is more detai
Canoe panel learning video
Google Chrome browser will support the function of selecting text translation
随机推荐
Webrtc quickly set up video call and video conference
AWT introduction
[microservice] Nacos cluster building and loading file configuration
509. Fibonacci number, all paths of climbing stairs, minimum cost of climbing stairs
Design and implementation of redis 7.0 multi part AOF
如何展开Collapse 的所有折叠面板
Upper computer software development - log information is stored in the database based on log4net
Detectron: train your own data set -- convert your own data format to coco format
Thinkphp6.0 middleware with limited access frequency think throttle
AWT介绍
Install pytoch geometric
HMS v1.0 appointment. PHP editid parameter SQL injection vulnerability (cve-2022-25491)
配置交叉编译工具链和环境变量
实用的小工具指令
AWT常用组件、FileDialog文件选择框
js arguments参数使用和详解
Introduction to AMBA
Weekly summary (*63): about positive energy
Yiwen unlocks Huawei's new cloud skills - the whole process of aiot development [device access - ESP end-to-side data collection [mqtt]- real time data analysis] (step-by-step screenshot is more detai
Uninstall Google drive hard drive - you must exit the program to uninstall