89. a^b

点击查看代码
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int N = 1e6 + 10;
ll a,b,p;
ll solve()
{
	ll ans=1;
	while(b)
	{
		if(b&1)
		ans=(ans*a)%p;
		b=b>>1;
		a=(a*a)%p;
	}
	return ans%p;
}
int main() {
	cin.tie(nullptr)->sync_with_stdio(false);
	cin>>a>>b;
	cin>>p;
	cout<<solve()<<endl;
	return 0 ^ 0;
}
posted @ 2023-02-13 19:26  xxj112  阅读(13)  评论(0)    收藏  举报