![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法竞赛进阶
陈情丶昕
这个作者很懒,什么都没留下…
展开
-
Acwing 90. 64位整数乘法
快速幂的思想 #include<bits/stdc++.h> using namespace std; typedef long long LL; int main() { LL a,b,p; cin>>a>>b>>p; LL ans = 0; while(b) { if(b&1) ans=(ans+a)%p;//手动模拟下就明白了 a=a*2%p; ...原创 2021-06-04 17:03:26 · 65 阅读 · 0 评论 -
Acwing 89.a^b
求a的b次方对pp取模的值。 输入格式 三个整数a,b,pa,b,p,在同一行用空格隔开。 输出格式 输出一个整数,表示a^b mod p的值。 数据范围 0≤a,b≤1090≤a,b≤109 1≤p≤1091≤p≤109 输入样例: 3 2 7 输出样例: 2 ...原创 2021-06-04 16:31:58 · 81 阅读 · 0 评论