72分WA求助!!!
查看原帖
72分WA求助!!!
982255
Redstone_Wizard楼主2024/5/19 20:07
#include<bits/stdc++.h>
using namespace std;
int a,b,p;
int quick_pow(int a,int b,int p){
	a = a%p;
	int ans = 1;
	while(b){
		if(b&1 == 1)ans = (ans*a)%p;
		a = (a*a)%p;
		b = b >> 1;
	}
	return ans;
}
int main(){
	cin >> a >> b >> p;
	//cout << a << " " << b << " " << p << endl;
	cout << a << '^' << b << " mod " << p << '=' << quick_pow(a,b,p);
	return 0;
}

72分,怎么都检查不出问题,后两个测试点WA,其他AC

2024/5/19 20:07
加载中...