求助
查看原帖
求助
373959
AFwhcing楼主2022/10/30 11:59

不懂就问 T1 for循环能不能过

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <climits>
#include <algorithm>
using namespace std;

typedef long long ll;
void read(int &x) {
	int k = 1, cnt = 0;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') k = -k;
		ch = getchar();
	}
	while (isdigit(ch)) {
		cnt = cnt * 10 + ch - '0';
		ch = getchar();
	}
	x = cnt * k;
}
void print(int x) {
	if (x < 0) x = -x, putchar('-');
	if (x < 10) putchar(x + '0');
	else {
		print(x / 10);
		putchar(x % 10 + '0');
	}
}
ll a, b, c, i; 
int main() {
	scanf("%lld%lld", &a, &b);
	for (i = 0, c = 1; i < b; ++i) {
		c *= a;
		if (c > (ll) 1e9) {
			puts("-1");
			return 0;
		}
	}
	printf("%lld\n", c);
	return 0;
}
2022/10/30 11:59
加载中...