#include <iostream>
#define ull unsigned long long
using namespace std;
ull fastpow(ull a,ull b,ull mod)
{
ull ans=1;
while(b!=0)
{
if(b&1)ans=ans*a%mod;
b>>=1;
a=a*a%mod;
}
return ans%mod;
}
int main()
{
ull a,b,mod;
cin>>a>>b>>mod;
cout<<fastpow(a,b,mod)%mod;
return 0;
}
【算法模板】快速幂
猜你喜欢
转载自blog.csdn.net/ezluoyiqi/article/details/82957617
今日推荐
周排行