记录编号 603791 评测结果 AAAAAAAAAA
题目名称 3777.[CSP 2022J]乘方 最终得分 100
用户昵称 Gravatarfather 是否通过 通过
代码语言 C++ 运行时间 0.027 s
提交时间 2025-07-23 19:04:00 内存使用 3.70 MiB
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
unsigned long long mmax=1e9,a,b,ans=1;
int main(){
	freopen("csp2022pj_pow.in","r",stdin);
	freopen("csp2022pj_pow.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>a>>b;
	if(a==1){
		cout<<1<<endl;
		return 0;
	}
	for(int i=1;i<=b&&ans<=mmax;i++){
		ans*=a;
	}
	if(ans<=mmax){
		cout<<ans<<endl;
	}
	else{
		cout<<"-1"<<endl;
	}
	return 0;
}