简答题
偏难
#22108
乘方(pow)
乘方(pow)


答案与解析
正确答案:<pre class="brush:cpp;toolbar:false">#include <bits/stdc++.h>
using namespace std;
int main() {
long long ans, a, b;
ans = 1;
cin >> a >> b;
if (a == 1) { // 特判a=1,避免超时
cout << ans;
} else {
for (int i = 1; i <= b; ++i) {
ans *= a; // b个a相乘
if (ans > 1e9) { // 若乘积超过10^9,直接输出-1并终止程序
cout << -1;
return 0;
}
}
cout << ans; // 输出b个a相乘的结果
}
return 0;
}</pre><p><br/></p>
这道题暂未补解析。