ll PowMod(ll a,ll b,ll c)
{
ll result=1;
ll base=a%c;
while(b)
{
if(b&1)
result=(result*base)%c;
base=(base*base)%c;
b>>=1;
}
return result;
}
int pow(int a,int b)
{
if(b==0)
return 1;
if(b&1)
return a*pow(a,b-1);
else
{
int t=pos(a,b/2);
return t*t;
}
}
一些基本定理:
- ( a + b ) mod c = ((a mod c) + (b mod c)) mod c
- ( a * b ) mod c = ((a mod c) * (b mod c)) mod c