C++题解
2025-08-02 09:24:02
发布于:浙江
2阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int gcd(vector<int> ve){
while(ve.size()!=1){
int a=ve[0],b=ve[1];
ve.erase(ve.begin(),ve.begin()+2);
ve.insert(ve.begin(),__gcd(a,b));
}
return ve[0];
}
int main(){
vector<int>v;
int q;
cin>>q;
while(q--){
int x;cin>>x;
v.push_back(x);
}
cout<<gcd(v);
return 0;
}
这里空空如也
有帮助,赞一个