bdfz_2024_summer/test.cpp

28 lines
396 B
C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int b,e,m;
#ifdef OITEST
b=2;e=10;m=9;
#endif
#ifndef OITEST
cin>>b>>e>>m;
#endif
int r=1;
while(e>0){
if (e%2==1) {
r=(r*b)%m;
}
e=(e>>1);
b=(b*b)%m;
}
cout<<r<<endl;
#ifdef OITEST
assert(r==7);
#endif
}