快速幂

#include<bits/stdc++.h> //快速幂
using namespace std;
long long f(long long a,long long b)
{
long long res=1;
while(b)
{
if(b&1) res=res*a;
b>>=1;
x*=x;
}
return res;
}

 
#include<bits/stdc++.h> //快速幂取模
using namespace std;
long long f(long long a,long long b,long long c)
{
long long res=1,x=a%c;
while(b)
{
if(b&1) res=(res*x)%c;
b>>=1;
x=x*x%c;
}
return res;
}

 

 


快速幂取模三阶--->( a ^ (b ^ c ) ) % mod

 

posted @ 2019-07-30 13:45  Aaaa_mber  阅读(174)  评论(0编辑  收藏  举报