You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
620 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
freopen("pow.in", "r", stdin);
freopen("pow.out", "w", stdout);
LL a, b, res = 1;
cin >> a >> b;
//需要对a==1进行特判否则肯定会TLE一个点,为啥呢因为b的范围它是<=1e9!如果a是1会空跑1e9次
if (a == 1) {
printf("%d\n", 1);
exit(0);
}
for (LL i = 1; i <= b; i++) {
res *= a;
if (res > 1e9) {
printf("%d\n", -1);
exit(0);
}
}
printf("%lld\n", res);
return 0;
}