题目地址:https://www.acwing.com/problem/content/description/91/
AC代码
#include <bits/stdc++.h>
using namespace std;
long long fastPower(long long a, long long b,int mod) {
long long res = 1;
while (b > 0) {
if (b & 1)
res = res * a % mod;
b >>= 1;
a = (a * a) % mod;
}
return res % mod;
}
int main(){
int a,b,p;
cin>>a>>b>>p;
cout<<fastPower(a,b,p);
return 0;
}
总结
ACM的hello world
答案参考:https://blog.csdn.net/qq_19782019/article/details/85621386
网友评论