36分,求助
查看原帖
36分,求助
1489616
Echo_1015楼主2024/12/28 15:12
#include <iostream>
using namespace std;
long long a,b,c,d,e;
long long sum = 1;

void hanshu(){
	if(b%2==1){
		sum*=a%c;
		b--;
		b/=2;
		a = (a*a)%c;
	} else if(b%2==0){
		b/=2;
		a = (a*a)%c;
	}

}
int main(){
	cin>>a>>b>>c;
	d = a;
	e = b;
	while(b>1){
		hanshu();
	}
	cout << e << '^' << d << " mod " << c << "=" << sum*a%c;
	return 0;
}
2024/12/28 15:12
加载中...