You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
372 B

#include <bits/stdc++.h>
using namespace std;
//最大公约数,辗转相除法
int gcd(int a, int b) {
if (b == 0) return a;
return gcd(b, a % b);
}
int main() {
int n;
scanf("%d", &n);
int d = 0, a;
for (int i = 1; i <= n; i++) {
scanf("%d", &a);
d = gcd(d, abs(a));
}
printf("%d", d);
return 0;
}