#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sort stable_sort
#define endl '\n'
ll qpow(ll a,ll b,ll p)
{
ll ans=1;
while(b>0)
{
if(b&1)
{
ans=ans*a%p;
}
b>>=1;
a=a*a%p;
}
return ans%p;
}
int main()
{
ll a,b,p;
cin>>a>>b>>p;
cout<<a<<"^"<<b<<" mod "<<p<<"="<<qpow(a,b,p);
return 0;
}
标签:sort,a%,数论,ll,笔记,学习,long,ans,define
From: https://www.cnblogs.com/The-Shadow-Dragon/p/17640982.html