//快速幂(模m)算法:
long long power (long long a, long long b) // , long long m
{
long long ans = 1;
while (b)
{
if (b & 1)
{
ans = ans * a; // ans = (ans * a) % m; +;
}
b >>= 1;
a = a * a; // a = a * a % m; +;
}
return ans;
}
加个点心帮助理解: http://baike.baidu.com/link?url=rgGhxJ-w1bJPVYodvxA42eZZPZEd2mX5iY0OkMbciDOkYrp0SVw10uxggMbUttqXTMlgjgt6dBomCu_jBSMHG_