24pts 求调
查看原帖
24pts 求调
1071426
shx2011楼主2024/10/20 14:20

code:

#include<bits/stdc++.h>
using namespace std;
int a,b,P;
long long poww(int x,int y){
	int ans=1;
	while(y){
		if(y&1!=0){
			ans=(ans*x)%P;
		}
		x*=x;
		y>>=1;
	}
	return ans;
}
int main(){
	cin>>a>>b>>P;;
	cout<<a<<"^"<<b<<" mod "<<P<<"="<<poww(a,b);
	return 0;
}

2024/10/20 14:20
加载中...