#include <iostream>
#include <cmath>
using namespace std;
int main() {
double a, b;
double c, d;
cin >> a >> b;
if (a == 0)
{
cout << 0 << endl;
}
c = pow(a, b);
d = pow(10, 9);
if (c <= d) {
cout << c;
} else if ((c > d) || (-c <= d))
cout << "-1";
return 0;
}
这样 60
dalao给的代码是
#include <iostream>
#include <cmath>
using namespace std;
unsigned long long a, b, c;
int main() {
cin >> a >> b;
if (a == 0)
{
cout << 0 << endl;
return 0;
}
c = pow(a, b);
if ((c > long(1e9)) || c == 0 ) {
cout << "-1";
return 0;
}
cout << c << endl;
return 0;
}
这个就AC了 为什么啊