题解
2025-08-05 13:49:17
发布于:浙江
1阅读
0回复
0点赞
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a,b,p,ans;
int fast_pow(int x,int y,int mod) {
int res=1;
while(y) {
if(y%2) {
res=res*x%mod;
}
y/=2;
x=x*x%mod;
}
return res;
}
signed main() {
scanf("%lld %lld %lld",&a,&b,&p);
ans=fast_pow(a,b,p);
printf("%lld^%lld mod %lld=%lld",a,b,p,ans);
return 0;
}
这里空空如也
有帮助,赞一个