当前位置:网站首页>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;
}
边栏推荐
- pytorch是什么?解释pytorch的基本概念
- How to handle different types of data
- Kotlin 协程的作用域构建器 coroutineScope与runBlocking 与supervisorScope,协程同步运行,协程挂掉的时候其他协程如何不被挂掉。
- ImportError: cannot import name 'get_ora_doc' from partially initialized module
- The grass is bearing seeds
- Self use notes for problem brushing learning
- 什么是 Meebits?一个简短的解释
- [JS component] create a custom horizontal and vertical scroll bar following the steam style
- [JS] solve the problem that removeeventlistener is invalid after the class listening event from new is bound to this
- How many rounds of deep learning training? How many iterations?
猜你喜欢
Common skills for quantitative investment - drawing 3: drawing the golden section line
How to solve the duplication problem when MySQL inserts data in batches?
Learning and Development notes of mongdb
阿姨学代码续集:能力吊打大批程序员
ROS2之OpenCV人脸识别foxy~galactic~humble
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
Expression tree - medium order printout
Canvas game 2048 free map size
Win10 home vs pro vs enterprise vs enterprise LTSC
How to determine whether T is a value type in a generic type or a reference class- How to determine whether T is a value type or reference class in generic?
随机推荐
How to handle different types of data
人神共愤,唐山“群殴女性事件”细节...
MySQL lpad() and rpad() concatenate string functions with specified length
[JS] battle chess
Antdpro - protable realizes the linkage effect of two selection boxes
Download nail live playback through packet capturing
天津银行周传凯:从 0 到 1,我的分布式数据库落地经验谈
Jenkins持续集成操作
What is meebits? A brief explanation
Oceanbase is the leader in the magic quadrant of China's database in 2021
pytorch和tensorflow有什么区别?
Druid reports an error connection holder is null
What is dummy change?
Zhouchuankai, Bank of Tianjin: from 0 to 1, my experience in implementing distributed databases
How to solve the duplication problem when MySQL inserts data in batches?
Pipeline pipeline project construction
Aof persistence
MySQL exception: com mysql. jdbc. PacketTooBigException: Packet for query is too large(4223215 > 4194304)
Androi天气
五篇经典好文,值得一看(2)