src2020/1668_zuidagongyue/main.cpp

28 lines
480 B
C++

#include <iostream>
using namespace std;
int find(int yi,int er){
//cout<<yi<<" "<<er<<endl;
if(yi%er==0){
return er;
}else{
return find(er,yi%er);
}
}
int main()
{
int n,last;
cin>>n;
cin>>last;
for(int i=1;i<n;i++){
int now;
cin>>now;
if(last<now){
int cg=last;
last=now;
now=cg;
}
last=find(last,now);
}
cout<<last;
}