//
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL fastpow( LL in,LL n,LL p ) // LL
{
LL ans=1;
while( n )
{
if( n&1 ) ans=( ans%p*in%p )%p;
in=( in%p*in%p )%p;
n>>=1;
}
return ans%p;
}
int main()
{
LL a,b,p;
while( cin>>a>>b>>p )
{
printf("%lld^%lld mod %lld=%lld\n",a,b,p,fastpow( a,b,p ) );
}
return 0;
}
洛谷_P1226 【模板】快速幂||取余运算_快速幂取余
猜你喜欢
转载自blog.csdn.net/qq_63173957/article/details/125339831
今日推荐
周排行