# 題目

AP325 Q-2-4. 快速冪 --200 位整數

# 解題思路

目前沒東西...

# 程式碼

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL a,b,c;
string s;
LL superpow(int x,int y,int z){
    if(y==0) return 1;
    if(y&1) return superpow(x,y-1,z)*x%z;
    LL sp=superpow(x,y/2,z)%z;
    return (sp*sp)%z;
}
int main(){
    cin>>s>>b>>c;
    a=s[0]-48;
    for(int i=1;i<(int)s.size();i++){
        a=(a*10%c+(s[i]-48))%c;
    }
    cout<<superpow(a,b,c);
}