50 分-求助!!
查看原帖
50 分-求助!!
1352651
SunriseLJY楼主2024/7/29 09:17

大佬们,给给思路吧。。。

40分代码:

#include<iostream>
using namespace std;

int main(){
	long long a, b, s;
	
	cin>>a>>b;
	s = a;
	
	if((a>10 && b>9) || (a>9 && b>10)){
		cout<<-1<<endl;
	}
	else{
		for(long long i=0; i<b; i++){
			s *= a;
		}
		cout<<s<<endl;
	}
	
	return 0;
}

50分代码:

#include<iostream>
using namespace std;

int main(){
	long long a, b, s;
	
	cin>>a>>b;
	s = a;
	
	for(long long i=0; i<b; i++){
		s *= a;
	}
	
	if(s>1000000000){
		cout<<-1<<endl;
	}
	else{
		cout<<s<<endl;
	}
	
	return 0;
}
2024/7/29 09:17
加载中...