90分求助QAQ
查看原帖
90分求助QAQ
539200
Trump_楼主2023/7/21 18:40
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>

using namespace std;

long long a, b;

long long QuickPower(long long a, long long k) {
	long long ans = 1, base = a;
	while (k != 0) {
		if (k & 1) {
			ans *= base;
		}
		if (ans > 1000000000) return -1;
		base *= base;
		k >>= 1;
	}
	return ans;
}

int main() {
	scanf("%lld%lld", &a, &b);
	printf("%lld\n", QuickPower(a, b));
	return 0;
}
2023/7/21 18:40
加载中...