提示
注意数据范围
太氵了,没啥好说的了
#include <iostream>
#include <cstdio>
#include <cmath>
#include <iomanip>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#define int long long
#define MAXN signed(1e9)
#define INF signed(0x3f3f3f3f)
using namespace std;
int a, b;
inline int read()
{
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9'){
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
return x * f;
}
inline void write(int x)
{
if (x < 0) putchar('-'), x = -x;
if (x > 9) write(x / 10);
putchar(x % 10 + '0');
return ;
}
inline int pow(int a, int b)
{
if (a == 1) return 1;
if (a == 0) return 0;
if (a > MAXN) return -1;
if (a * b > MAXN) return -1;
int res = 1, up = a;
while (b > 0)
{
if (b % 2 == 1) res *= up;
if (res > MAXN) return -1;
up *= up, b >>= 1;
}
return (res > MAXN ? -1 : res);
}
signed main()
{
#ifdef ONLINE_JUDGE
#else
freopen("pow.in", "r", stdin);
freopen("pow.out", "w", stdout);
#endif
a = read(), b = read();
write(pow(a, b));
return 0;
}
// I love ** !!!