HakureiHaruhi
8/19/2018 - 7:04 AM

QuickPow

caculate a^b% mod m with quickpow algorithm

/*return a^b % m*/

LL getM(LL a, LL b, LL m)
{
	LL _sum = 1, base = a;
	
	while (b)
	{
		if (b&1)
			_sum = (_sum*base)%m;
		base = (base*base)%mod;
		b >>= 1;
	}
	return _sum;
}