题解 | 最大公约数1
最大公约数1
https://www.nowcoder.com/practice/021010dda9f04900a86738931a5600a4
#include <iostream>
#include <numeric>
#include <climits>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
while(cin >> n){
int xmax = INT_MIN;
int xmin = INT_MAX;
int x;
for(int i = 0; i < n; i++){
cin >> x;
xmax = max(x, xmax);
xmin = min(x, xmin);
}
int a = gcd(xmax, xmin);
cout << xmin << " " << xmax << " " << a << "\n";
}
return 0;
}