标签:blog http io os ar sp div c on
在这里看到了快速幂算法的有关推导(在此感谢~)
理解了这个算法本身之后,发现你忘了快速幂怎么打,对于noip2013 T1你也可以拿到80
所以看懂推导很重要(如果忘了,请认真看)
这里就mark一下模板好了(链接写的很详细,所以自己的推导就过了)
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
long long ans=1;
int a,b,c;
int main(){
scanf("%d%d%d",&a,&b,&c);//(a^b)%c
a%=c;
while(b>0){
if(b%2==1) ans=(ans*a)%c;
b/=2;
a=(a*a)%c;
}
cout<<ans;
return 0;
}
标签:blog http io os ar sp div c on
原文地址:http://www.cnblogs.com/polebug/p/4007943.html