-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboj1629.cpp
More file actions
45 lines (43 loc) · 754 Bytes
/
boj1629.cpp
File metadata and controls
45 lines (43 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <set>
#include <queue>
using namespace std;
using p = pair<int, int>;
using ll = long long;
const int MAX = 10e+6;
const int INF = 0x66554433;
inline void Quick_IO(){
ios_base :: sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
ll c;
ll calc(ll A, ll B){
if(B==0){
return 1%c;
}
if(B==1){
return A%c;
}
if(B%2==0){
ll a = calc(A, B/2);
return a*a%c;
}
else{
ll a = calc(A, B/2);
return (a*a)%c*A%c;
}
}
int main(){
Quick_IO();
ll A, B, C;
cin>>A>>B>>C;
c = C;
cout<<calc(A, B)%c<<"\n";
return 0;
}