Can anyone help me?
查看原帖
Can anyone help me?
1335977
Windy0430楼主2024/10/3 18:55
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
int main(){
	freopen("pow.in","r",stdin);
	freopen("pow.out","w",stdout);
	long long a , b;
	scanf("%ld %ld" , &a , &b);
	if(a == 1){
		printf("1");
		return 0;
	}
	if(b == 1){
		printf("%ld" , a);
		return 0;
	}
	if(a > 31622){
		printf("-1");
		return 0;
	}
	if(b > 29){
		printf("-1");
		return 0;
	}
	if(pow(a , b-1) > pow(10 , 9)){
		printf("-1");
	} else {
		int c = pow(a , b);
		printf("%ld" , c);
	}
	return 0;
}
2024/10/3 18:55
加载中...