#include<iostream>
using namespace std;
int a,b,sum=1;
bool limit=true;
int main() {
cin>>a>>b;
if(a==1) {
cout << 1 <<endl;
return 0;
}
if(b==1) {
cout << a <<endl;
return 0;
}
if(a>=31622 || b>=29) {
cout << -1 <<endl;
return 0;
}
for(int i=0; i<=b; i++) {
if(sum<=0) limit=false;
else sum*=a;
}
if(limit==true) cout<<sum;
else cout<<-1;
return 0;
}
代码如上,我的想法是先把该特判的都特判了,再通过有符号整数超过范围变负数的特性判断,没有像神犇们那样开5维数组(或者堆,哈希。5维数组我认为没必要,堆和哈希我不会,所以只能使用变量sum了)我明明昨天还是70pts啊!