-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path374-Big Mod.cpp
More file actions
58 lines (46 loc) · 1.15 KB
/
374-Big Mod.cpp
File metadata and controls
58 lines (46 loc) · 1.15 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
/*----------------------|
/ Author : Ashraf Tasin |
/ Date : 08.08.19 |
/----------------------*/
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define all v.begin(),v.end()
#define flash ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define db double
#define endl "\n"
#define mnm pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>
#define show for(int i=0;i<v.size();i++) cout << v[i] << " ";
#define eps 1e-6
#define mx 100008
using namespace std;
/*King Moves
int dx[]={-1,1,-1,0,1,-1,0,1};
int dy[]={0,0,-1,-1,-1,1,1,1}; */
/*Knight Moves
int dx[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int dy[] = { 1, 2, 2, 1, -1, -2, -2, -1 }; */
/*Normal Moves
int x[] = {0, 1, 0, -1};
int y[] = {-1, 0, 1, 0}; */
ll bigmod(ll base,ll power,ll mod)
{
if(power==0) return 1%mod;
ll x=bigmod(base,power/2,mod);
x=(x*x)%mod;
if(power%2) x=(x*base)%mod;
return x;
}
int main()
{
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
flash
ll base,power,mod;
while(cin >> base >> power >> mod)
{
cout << bigmod(base,power,mod) << endl;
}
return 0;
}