0分求更改指错
查看原帖
0分求更改指错
1282944
sxLiang_1229楼主2024/10/7 22:04
#include<bits/stdc++.h>
#define LL long long
using namespace std;
LL fast_power(LL a,LL b,LL c){
	LL ans=1;
	a%=c;
	while(b){
		if(b&1){
			ans=(ans*a)%c;
		}else{
			a=(a*a)%c;
			b>>1;
		}
	}
	return ans;
}
int main(){
	LL a,b,c;
	scanf("%lld %lld %lld",&a,&b,&c);
	LL ans=fast_power(a,b,c);
	ans%=c;
	printf("%lld^%lld mod %lld=%lld",a,b,c,ans);
	return 0;
}
2024/10/7 22:04
加载中...