凌艺樽 • 4个月前
#include <queue>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <iomanip>
#include <string.h>
#include <algorithm>
using namespace std;
#define LL long long
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
LL power(LL a,LL b,LL p)
{
if(a==0)
return 0;
if(b==1)
return 0%p;
LL ans=1;
while(b!=0)
{
if(b%2 ==1)
{
ans=(ans*a)%p;
}
b=b/2;
a=(a*a)%p;
}
return ans%p;
}
int main ()
{
LL a,b,p;
cin >> a >> b >> p;
cout << power(a,b,p);
return 0;
}
评论: