都是60分的代码:
第一份代码:
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+5;
long long a,b;
long long qpow(long long x,long long y){
long long ans=1;
while(y--){
ans*=x;
}
return ans;
}
int main(){
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>a>>b;
if(qpow(a,b)<=int(1e9)) cout<<qpow(a,b);
else cout<<-1;
return 0;
}
第二份代码:
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+5;
long long a,b;
int main(){
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>a>>b;
if(pow(a,b)<=pow(10,9)) cout<<pow(a,b);
else cout<<-1;
return 0;
}
第一份代码记录
第二份代码记录