[문제 링크]
https://www.acmicpc.net/problem/1629
[입출력 예]
[소스코드]
//시작시간 10:48
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll func (int a, int b, int c){
if (b==1){
return a % c;
}
if (b%2 ==0){
return func(a, b/2, c)*func(a,b/2,c)%c;
}
else {
return func(a,b/2,c)*func(a,b/2,c)%c*a%c;
}
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int a,b,c;
cin>>a>>b>>c;
cout<<func(a,b,c);
return 0;
}