2 条题解
-
119230217阳 (19230217) LV 7 @ 2023-12-26 18:42:14
#include<iostream>
using namespace std;
int gcd(int a, int b)
{
if (b == 0)return a;
else return gcd(b, a % b);
}
int main()
{
int n; cin >> n;
int a[10000] = { 0 };
for (int i = 0; i < n; i++)
cin >> a[i];
int g = gcd(a[0],a[1]);
for (int i = 2; i < n; i++)
{
g = gcd(g, a[i]);
}
cout << g;
return 0;
} -
02021-01-22 21:52:01@
#include <iostream>
using namespace std;
int main()
{
long long x,x1,x2,x3,b;
cin>>x;
cin>>x1;
cin>>x2;
while(1)
{
long long r=x1%x2;
if(r==0)
break;
x1=x2; x2=r;
}
for(long long y=1; y<x-1; y++)
{
cin>>x3;
while(1)
{
long long k=x3%x2;
if(k==0)
break;
x3=x2; x2=k;
}
}
cout<<x2<<endl;
return 0;
}
- 1
信息
- 难度
- 7
- 分类
- (无)
- 标签
- 递交数
- 1215
- 已通过
- 210
- 通过率
- 17%
- 被复制
- 8
- 上传者