0分求助
查看原帖
0分求助
1200191
封禁用户楼主2024/10/23 21:38
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a,b,p;
ll quick_pow(ll n,ll x,ll p){
	ll res=0;
	while(n>0){
		if(n & 1){
			res*=x;
			res%=p;
		}
		x*=x;
		x%=p;
		n>>=1;
	}
	return res;
}
int main(){
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	cin>>a>>b>>p;
	ll ans=quick_pow(a,b,p);
	cout<<a<<"^"<<b<<" mod "<<p<<"="<<ans<<"\n";
	return 0;
}

2024/10/23 21:38
加载中...