模板
#include<iostream> using namespace std; int main() { long long a,b,p,res=1; cin>>a>>b>>p; res%=p; while(b){ if(b&1)res=res*1ll*a%p; b>>=1; a=1ll*a*a%p; } cout<<res; }