明天不能上了,还是把答案放这里吧
#include<iostream>
#include<cmath>
using namespace std;
long bigmod(long b,long p,long m){
if(p==0) return 1;
if(p%2==0) return (long)pow(bigmod(b,p/2,m),2.0) %m;
return ( b%m * bigmod(b,p-1,m) )%m;
}
int main(){
for(long B,P,M; cin>>B>>P>>M; )
cout<<bigmod(B,P,M)<<endl;
}