P5682 90分求助
  • 板块学术版
  • 楼主Jiji2012
  • 当前回复2
  • 已保存回复2
  • 发布时间2023/10/8 22:14
  • 上次更新2023/11/2 14:51:47
查看原帖
P5682 90分求助
907036
Jiji2012楼主2023/10/8 22:14
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int t;
	int max1 = -1, max2 = -1, max3 = -1;
	while(n--){
		cin >> t;
		if(t == max1 || t == max2 || t == max3) continue;
		if(t > max1){
			max3 = max2;
			max2 = max1 ;
			max1 = t;
		}else if(t > max2){
			max3 = max2;
			max2 = t;
		}else if(t > max1){
			max1 = t;
		}
	} 
	if(max2 == -1){
		cout << -1;
		return 0;
	}
	cout << max(max3 , max1 % max2);
	return 0;
}
2023/10/8 22:14
加载中...