文章
49
粉丝
90
获赞
9
访问
29.4k
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
int gcd(int a, int b)
{
if (b == 0)
return a;
return gcd(b, a % b);
}
int main()
{
int n;
cin >> n;
vector<int> v;
while (n--)
{
int t;
cin >> t;
v.emplace_back(t);
}
auto max = max_element(v.begin(), v.end());
auto min = min_element(v.begin(), v.end());
int gcd_of_them = gcd(*max, *min);
cout << *min << " " << *max << " " << gcd_of_them << endl;
return 0;
}
登录后发布评论
暂无评论,来抢沙发