#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<cmath> #include<algorithm> using namespace std; long long a,b,MOD,ans=1; int main() { scanf("%lld%lld%lld",&a,&b,&MOD); while(b) { if(b&1) ans=ans*a%MOD;//如果b为单数,乘到ans里面去,然后取模 a=a*a%MOD; b=b>>1; } printf("%lld",ans); return 0; }