题解 | #最大公约数1#库函数秒了
最大公约数1
https://www.nowcoder.com/practice/021010dda9f04900a86738931a5600a4
#include <bits/stdc++.h> //#include <iostream> //#include <vector> //#include <numeric> //#include <algorithm> using namespace std; int main(){ int n; while (cin>>n){ vector<int> v(n); for(int i=0;i<n;i++){ cin>>v[i]; } auto minnum=min_element(v.begin(),v.end()); auto maxnum=max_element(v.begin(),v.end()); int gcdnum=gcd(*minnum,*maxnum); cout<<*minnum<<" "<<*maxnum<<" "<<gcdnum<<endl; } return 0; }