当前位置:网站首页>Quick power explanation
Quick power explanation
2022-06-13 00:56:00 【-LM-】
Fast power
Time complexity O(logn)
(a + b) modp=(a modp + b modp) modp
(a - b) modp = (a modp - b modp + p) modp
a * b modp = a modp * b modp
const long long mod=1e9+7;
long long fastpow(long long x,long long y){
x%=mod;
long long res=1;
while(y){
if(y & 1) res=res*x%mod;
y>>=1;
x=x*x%mod;
}
return res;
}
边栏推荐
猜你喜欢

How to solve the duplication problem when MySQL inserts data in batches?

Common skills for quantitative investment - drawing 3: drawing the golden section line

Arduino controls tb6600 driver +42 stepper motor

. The way to prove the effect of throwing exceptions on performance in. Net core

Liu Hui and introduction to nine chapter arithmetic and island arithmetic

今日睡眠质量记录74分

Aunt learning code sequel: ability to sling a large number of programmers

Arduino control soil moisture sensor

Common skills of quantitative investment -- Drawing Part 1: Drawing stock closing price curve and ochl candle chart

Kotlin coroutine suspend function suspend keyword
随机推荐
The scope builder coroutinescope, runblocking and supervisorscope of kotlin collaboration processes run synchronously. How can other collaboration processes not be suspended when the collaboration pro
Opencv face recognition of ros2 foxy~galactic~humble
[JS component] customize the right-click menu
Today's sleep quality record 74 points
单片机串口中断以及消息收发处理——对接受信息进行判断实现控制
Cards are unpredictable
【北亚服务器数据恢复】虚拟机文件丢失导致Hyper-V服务瘫痪的数据恢复案例
Androi天气
MySQL queries the quantity of each month and the year-on-year and month on month data of each month
【服务器数据恢复】存储服务器之间迁移数据时数据丢失恢复成功案例
gpu加速pytorch能用吗?
ImportError: cannot import name 'get_ora_doc' from partially initialized module
Canvas airplane game
Canvas game lower level 100
Four startup modes of kotlin collaboration
Androi weather
Google play console crash information collection
Kotlin 协程的作用域构建器 coroutineScope与runBlocking 与supervisorScope,协程同步运行,协程挂掉的时候其他协程如何不被挂掉。
People and gods are angry. Details of Tangshan "mass beating of women incident"
kotlin 协程withContext切换线程