灌水区有大佬
  • 板块灌水区
  • 楼主zzx_666
  • 当前回复8
  • 已保存回复8
  • 发布时间2023/10/3 14:05
  • 上次更新2023/11/2 16:19:34
查看原帖
灌水区有大佬
1036298
zzx_666楼主2023/10/3 14:05

p7923

35分

代码

#include<iostream>
#include<cstring>
using namespace std;
int pow(long long a,long long b){
	long long tmp=1;
	for(int i=0;i<b;i++){
		tmp*=a;
	}
	return tmp;
}
long long n,max2=-1145141919,min2=1145141919,fmax=0,fmin=0;
char x;
int main(){
	cin>>n>>x;
	for(int i=0;i<n;i++){
		char a[105];
		cin>>a;
		if(a[1]=='>'){
			int tmp=1,flag=0;
			for(int j=1;j<strlen(a);j++){
				if(a[j]=='-'){
					flag=1;
				}
				if(a[j]>='0'&&a[j]<='9'){
					if(flag){
						tmp+=-1*pow(10,strlen(a)-j-1)*(a[j]-'0');
					}
					else{
						tmp+=pow(10,strlen(a)-j-1)*(a[j]-'0');
					}
				}
			}
			tmp-=1;//这不知道为什么老是加一
			if(tmp>max2){
				max2=tmp;
				if(a[2]=='='){
					fmax=1;
				}
				else{
					fmax=0;
				}
			}
			if(tmp==max2){
				if(a[2]!='='){
					fmax=0;
				}
			}
		}
		if(a[1]=='<'){
			int tmp=1,flag=0;
			for(int j=1;j<strlen(a);j++){
				if(a[j]=='-'){
					flag=1;
				}
				if(a[j]>='0'&&a[j]<='9'){
					if(flag){
						tmp+=-1*pow(10,strlen(a)-j-1)*(a[j]-'0');
					}
					else{
						tmp+=pow(10,strlen(a)-j-1)*(a[j]-'0');
					}
				}
			}
			tmp-=1;//这也是
			if(tmp<min2){
				min2=tmp;
				if(a[2]=='='){
					fmin=1;
				}
				else{
					fmin=0;
				}
			}
			if(tmp==min2){
				if(a[2]!='='){
					fmin=0;
				}
			}
		}
	}
	if(max2>min2){
		cout<<"No Answer!";
		return 0;
	}
	if(max2!=-1145141919&&min2!=1145141919){
		cout<<max2<<"<";
		if(fmax) cout<<"=";
		cout<<x<<"<";
		if(fmin) cout<<"=";
		cout<<min2;
	}
	else if(max2!=-1145141919){
		cout<<x<<">";
		if(fmax) cout<<"=";
		cout<<max2;
	}
	else if(min2!=1145141919){
		cout<<x<<"<";
		if(fmin) cout<<"=";
		cout<<min2;
	}
	return 0;
}

捞!

2023/10/3 14:05
加载中...