P4549 【模板】裴蜀定理
1 #include <bits/stdc++.h> 2 using namespace std; 3 int main() { 4 int n; scanf("%d",&n); 5 int ans; 6 for (int i = 1; i <= n; ++i) { 7 int x; scanf("%d",&x); 8 x = abs(x); 9 if (i == 1) ans = x; 10 else ans = __gcd(ans,x); 11 } 12 printf("%d\n",ans); 13 return 0; 14 }