当前位置:网站首页>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;
}
边栏推荐
- 1.1 history of Statistics
- Sword finger offer II 038 Daily temperature
- Compound nonlinear feedback control (2)
- ES6 modularization
- 安装 Pytorch geometric
- HMS v1.0 appointment.php editid参数 SQL注入漏洞(CVE-2022-25491)
- buuctf-pwn write-ups (8)
- Detectron:训练自己的数据集——将自己的数据格式转换成COCO格式
- 如何展开Collapse 的所有折叠面板
- "In simple language programming competition (basic)" part 1 Introduction to language Chapter 3 branch structure programming
猜你喜欢
Impact relay jc-7/11/dc110v
My NVIDIA developer journey - optimizing graphics card performance
Sword finger offer II 038 Daily temperature
Overview of relevant subclasses of beanfactorypostprocessor and beanpostprocessor
Component、Container容器常用API详解:Frame、Panel、ScrollPane
【微服务】Nacos集群搭建以及加载文件配置
Accidentally deleted the data file of Clickhouse, can it be restored?
Online shrimp music will be closed in January next year. Netizens call No
ANSYS command
Detailed explanation of common APIs for component and container containers: frame, panel, scrollpane
随机推荐
el-select如何实现懒加载(带搜索功能)
Google Chrome browser will support the function of selecting text translation
如何展开Collapse 的所有折叠面板
SQL injection - injection based on MSSQL (SQL Server)
How to get the parent node of all nodes in El tree
C语言中的函数(详解)
报错cvc-complex-type.2.4.a: 发现了以元素 ‘base-extension‘ 开头的无效内容。应以 ‘{layoutlib}‘ 之一开头。
[openvino+paddle] paddle detection / OCR / SEG export based on paddle2onnx
Practical gadget instructions
Nexus 6p从8.0降级6.0+root
How to expand all collapse panels
实用的小工具指令
4G wireless all network solar hydrological equipment power monitoring system bms110
Halcon图片标定,使得后续图片处理过后变成与模板图片一样
fastjson
Sword finger offer II 038 Daily temperature
Invalid revision: 3.18.1-g262b901-dirty
Excel 比较日器
QT releases multilingual International Translation
如何判断数组中是否含有某个元素