qp求救
查看原帖
qp求救
1358961
LG_Sam楼主2024/10/3 14:17

rt(qp=quickpow)

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int b,p;
int qp(int x,int y){
	ll ans=1;
	while(y){
		if(y%2==1) ans=1LL*ans*x;
		x=1LL*x*x;
		y/=2;
	}
	return ans;
}
int main(){
	cin>>b>>p;
	ll v=qp(b,p);
	if(v>1e9) cout<<-1;
	else cout<<v;
	return 0;
}
2024/10/3 14:17
加载中...