Files
python/TangDou/CSP-J/J2-2022/pow2.cpp

28 lines
477 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
freopen("pow.in", "r", stdin);
freopen("pow.out", "w", stdout);
int a, b;
cin >> a >> b;
LL res = 1;
if (a == 1) {
printf("1");
exit(0);
}
for (int i = 1; i <= b; i++) {
res *= a;
if (res > 1e9) {
puts("-1");
exit(0);
}
}
printf("%lld\n", res);
return 0;
}